Skip to content

Docker Compose support does not work in AOT-processed testsΒ #36273

Open

Description

@wilkinsona

This can be reproduced using Petclinic's tests with AOT enabled:

tasks.named('test') {
  useJUnitPlatform()
  systemProperty "spring.aot.enabled", true
}

./gradlew test fails with both tests in PostgresIntegrationTests failing as they could not connect to Postgres. They try to use the default host and port rather than those of a container starter by Docker Compose.

Activity

  1. added this to the 3.1.x milestone on Jul 7, 2023
  2. added
    theme: aotAn issue related to Ahead-of-time processing
    on Aug 24, 2023
  3. roxspring commented on Dec 5, 2023

    @roxspring

    Any idea what needs to be done to fix this? Failing the PetClinic Gradle build because Docker isn't available seems really odd - I didn't think Docker was a hard requirement?

  4. modified the milestones: 3.1.x, 3.2.x on Apr 22, 2024
  5. scottfrederick commented on Apr 26, 2024

    @scottfrederick
    Contributor

    Docker Compose support is explicitly disabled when spring.aot.enabled is true:

    if (Boolean.getBoolean("spring.aot.processing") || AotDetector.useGeneratedArtifacts()) {
    logger.trace("Docker Compose support disabled with AOT and native images");
    return;
    }

    We could potentially change AotDetector.useGeneratedArtifacts() there to NativeDetector.inNativeImage() to fix this problem, but there's some history behind that in #35548 and #35676 and I'm not sure what other side-effects making that change would have.

  6. wilkinsona commented on Apr 29, 2024

    @wilkinsona
    MemberAuthor

    Thanks, Scott. #35548 and #35676 were about preventing the Docker Compose support from breaking things by getting it to back off when AOT processing or building a native image. This issue's about removing the need for that by getting it to work after AOT processing or in a native image.

    The failure that I described (not very clearly) above is occurring because the Docker Compose support has backed off, leaving the tests looking for a DB on its default host and port rather than from a Compose-managed container. If we can get this to work after AOT processing or in a native image then I think we can safely stop making the support back off in those situations.

  7. modified the milestones: 3.2.x, 3.3.x on Nov 20, 2024
  8. modified the milestones: 3.3.x, 3.4.x on Jun 18, 2025
  9. herder commented on Sep 29, 2025

    @herder

    Will this mean that we can never build projects using Docker Compose for integration tests with AOT processing?

    Or maybe I'm misunderstanding the issue?

    We have quite a few projects where it's important we run the ITs against the same PG version as in prod, so I'd love to be wrong :)

  10. wilkinsona commented on Sep 29, 2025

    @wilkinsona
    MemberAuthor

    It should be fine, unless you want to AOT-process your tests. Generally speaking, I wouldn't recommend that unless you want to run the tests in a native image.

  11. herder commented on Sep 29, 2025

    @herder

    Got it - thanks for the clarification!

  12. modified the milestones: 3.4.x, 3.5.x on Nov 11, 2025
  13. modified the milestones: 3.5.x, 4.0.x on Jun 25, 2026
  14. added a commit that references this issue on Aug 6, 2026
    f398093
  15. goutamadwant commented on Aug 6, 2026

    @goutamadwant

    @wilkinsona I’ve opened #51287 to address this issue.
    So the change allows Docker Compose connection details to participate in test AOT processing while preserving the existing backoff for application AOT processing. The temporary connection details are excluded from generated registrations and recreated when the AOT-processed test runs. Let me know if this looks good or any suggestions! thanks.

  16. tchowdhury101 commented on Nov 3, 2026

    @tchowdhury101

    Hi, I'd like to work on this. Is it open for contribution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme: aotAn issue related to Ahead-of-time processingtype: bugA general bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions