testcontainers-java icon indicating copy to clipboard operation
testcontainers-java copied to clipboard

Docker Compose service suffix changed from `_1` to `-1`

Open mxab opened this issue 3 years ago • 5 comments

Hi, I'm not sure when this change happened but it seems one of the latest docker-compose desktop version changed the suffix naming pattern for services from _1 to -1

This let's my tests fail as the lookup doesn't work anymore

564eae8ef285   zzsybrtief7r_pdf        "docker-entrypoint.s…"   ...  3000/tcp       zzsybrtief7r-pdf-1
e8ddf410a42c   zzsybrtief7r_dummy      "/docker-entrypoint.…"   ...  80/tcp         zzsybrtief7r-dummy-1

 Caused by:
        org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
            at app//org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
            at app//org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:329)
            ... 106 more

            Caused by:
            org.testcontainers.containers.ContainerLaunchException: Could not create/start container
                at app//org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:525)
                at app//org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:331)
                at app//org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
                ... 107 more

                Caused by:
                org.testcontainers.containers.ContainerLaunchException: Aborting attempt to link to container zzsybrtief7r_pdf_1 as it is not running
                    at app//org.testcontainers.containers.GenericContainer.applyConfiguration(GenericContainer.java:815)
                    at app//org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:365)
                    ... 109 more

If I change my exposed service setting to -1 like this:

@Container
    val pdf = DockerComposeContainer(...)
        .withLocalCompose(true)
        .withExposedService("pdf-1", 3000) // change from _1 to -1
        .withBuild(true)

The error gets stranger:

...
ContainerLaunchException: Aborting attempt to link to container jjz1pmny2gn9_pdf-1_1 as it is not running

❯ docker-compose --version Docker Compose version v2.3.3


Docker Desktop Version `4.6.0 (75818)`

OS: MacBook Pro (16", 2021)
M1 Pro

mxab avatar Mar 23 '22 19:03 mxab

Ok the change to -1 happens when Use Docker Compose V2 is enabled

mxab avatar Mar 23 '22 19:03 mxab

I too facing the similar issue. Here is my config: docker: Client: Docker Engine - Community Version: 20.10.14

docker-compose: Docker Compose version 2.3.4

docker-meachine: docker-machine version 0.16.2, build bd45ab13

docker-desktop: Version 4.6.1 (76265)

OS: macOS Monterey(version 12.3) M1 Chip

@mxab can you suggest, how did you switch back to the old version of docker-compose

govardhanaraoganji avatar Mar 30 '22 20:03 govardhanaraoganji

@govardhanaraoganji In Docker Desktop for Windows, this is a setting in their UI. I'd assume there is something similar on Mac.

image

kiview avatar Mar 31 '22 06:03 kiview

I realized that when I have issue. I have installed docker, docker-compose, docker-machine manually with brew command. It is working fine, after removed all the references of it.

Thank you @kiview and I have disabled the v2 on Docker Desktop.

govardhanaraoganji avatar Mar 31 '22 10:03 govardhanaraoganji

Bumping this for visibility. Lost few hours on head scratching because of "-1" vs "_1"

Szer avatar Jun 14 '22 16:06 Szer

Closing because there is already an issue related to support for compose v2 https://github.com/testcontainers/testcontainers-java/issues/4565

There is also a PR you can follow.

eddumelendez avatar Oct 31 '22 17:10 eddumelendez