镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[Bug]: Unable to override Docker Image via testcontainers.properties when using ComposeContainer #9222

Closed

Description

@apoorvg03

Module

Core

Testcontainers version

1.20.1

Using the latest Testcontainers version?

Yes

Host OS

macOS

Host Arch

x86

Docker version

Client:
 Cloud integration: 1.0.17
 Version:           20.10.8
 API version:       1.41
 Go version:        go1.16.6
 Git commit:        3967b7d
 Built:             Fri Jul 30 19:55:20 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.8
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.6
  Git commit:       75249d8
  Built:            Fri Jul 30 19:52:10 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

What happened?

I am attempting to override the default Docker Image version used in ComposeContainer by specifying a custom image version via compose.container.image in testcontainers.properties. However, the override does not seem to take effect and the container still uses the default version which is 24.0.2.

testcontainers.properties file:

compose.container.image=docker:25.0.2

Relevant log output

08:16:41.871 [main] INFO tc.docker:24.0.2 -- Creating container for image: docker:24.0.2

Additional Information

No response

Activity

  1. fokion commented on Sep 21, 2024

    @fokion
    Contributor

    I can have a look if you want @eddumelendez

  2. fokion commented on Sep 21, 2024

    @fokion
    Contributor

    Based on an initial view I see the issue at ComposeContainer as the constructor creates a compose delegate based on the DEFAULT_IMAGE_NAME instead of checking if we have a property override.

    public ComposeContainer(String identifier, List<File> composeFiles) {
            this.composeDelegate =
                new ComposeDelegate(
                    ComposeDelegate.ComposeVersion.V2,
                    composeFiles,
                    identifier,
                    COMPOSE_EXECUTABLE,
                    DEFAULT_IMAGE_NAME
                );
            this.project = this.composeDelegate.getProject();
        }
    
  3. fokion commented on Sep 21, 2024

    @fokion
    Contributor

    @eddumelendez feel free to review on this one :)

  4. eddumelendez commented on Oct 17, 2024

    @eddumelendez
    Member

    Hi, the approach we would like to follow is

    • Add new constructors allowing for an image name
    public ComposeContainer(DockerImageName image, File... composeFiles) {}
    
    public ComposeContainer(DockerImageName image, List<File> composeFiles) {}
    
    public ComposeContainer(DockerImageName image, String identifier, File... composeFiles) {}
    
    public ComposeContainer(DockerImageName image, String identifier, List<File> composeFiles) {}
    • Log warning if withLocal(true) is used in conjunction with custom image name (since image would not be used)

    • Consider changes in DockerComposeContainer as well

    This way the implementation aligns with other modules.

  5. fokion commented on Oct 18, 2024

    @fokion
    Contributor

    Do you want to assign it to me?

  6. juliojgd commented on Jan 16, 2025

    @juliojgd

    Hi @eddumelendez @fokion , is anybody already working on this?

  7. fokion commented on Jan 16, 2025

    @fokion
    Contributor

    I am still waiting to either assign it to me or if it is lower in priority do something else... :)

  8. eddumelendez commented on Jan 16, 2025

    @eddumelendez
    Member

    @fokion the issue is yours

  9. fokion commented on Jan 17, 2025

    @fokion
    Contributor

    will have a look this weekend and update based on your comments

  10. fokion commented on Jan 21, 2025

    @fokion
    Contributor

    I updated the old pr to have some new commits based on the feedback on constructors.

  11. viktorgt commented on Mar 31, 2025

    @viktorgt

    Any news on this?

  12. m4rii0 commented on Apr 2, 2025

    @m4rii0
    Contributor

    Hello, @fokion and @eddumelendez it would be great to support the DEFAULT_IMAGE_NAME

    private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("docker:24.0.2");

    in the CONTAINER_MAPPING map

    private static final ImmutableMap<DockerImageName, String> CONTAINER_MAPPING = ImmutableMap
    .<DockerImageName, String>builder()
    .put(DockerImageName.parse(AMBASSADOR_IMAGE), "ambassador.container.image")
    .put(DockerImageName.parse(SOCAT_IMAGE), "socat.container.image")
    .put(DockerImageName.parse(VNC_RECORDER_IMAGE), "vncrecorder.container.image")
    .put(DockerImageName.parse(COMPOSE_IMAGE), "compose.container.image")
    .put(DockerImageName.parse(ALPINE_IMAGE), "tinyimage.container.image")
    .put(DockerImageName.parse(RYUK_IMAGE), "ryuk.container.image")
    .put(DockerImageName.parse(KAFKA_IMAGE), "kafka.container.image")
    .put(DockerImageName.parse(PULSAR_IMAGE), "pulsar.container.image")
    .put(DockerImageName.parse(LOCALSTACK_IMAGE), "localstack.container.image")
    .put(DockerImageName.parse(SSHD_IMAGE), "sshd.container.image")
    .put(DockerImageName.parse(ORACLE_IMAGE), "oracle.container.image")
    .build();

    So anyone can override this option if needed :), what do you guys think about it?

  13. added a commit that references this issue on Oct 10, 2025
    9cbe138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions