Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with running test containers within another container #4785

Closed
avst-dmartino opened this issue Dec 15, 2021 · 4 comments
Closed

Issue with running test containers within another container #4785

avst-dmartino opened this issue Dec 15, 2021 · 4 comments

Comments

@avst-dmartino
Copy link

avst-dmartino commented Dec 15, 2021

So I am having the following issue using testcontainers within another docker container.

Steps to reproduce

  • Run a ubuntu docker container using latest tag with docker socket from the host machine mounted. I have also found this on Amazon Linux's container.

  • Add any dependencies you need to the image, git, maven etc

  • Using Testcontainers version 1.16.2 create a docker compose container like this:

    @container
    public static DockerComposeContainer environment =
    new DockerComposeContainer(new File("src/test/resources/docker-compose.yml"))
    .withExposedService(ClientTestHelper.SERVICE_NAME, ClientTestHelper.PORT)
    .withExposedService(lientTestHelper.LOCALSTACK_SERVICE_NAME, DigClientTestHelper.LOCALSTACK_PORT)
    .withLogConsumer(ClientTestHelper.SERVICE_NAME, SLF4J_LOG_CONSUMER)
    .withLogConsumer(ClientTestHelper.LOCALSTACK_SERVICE_NAME, SLF4J_LOG_CONSUMER)
    .withLocalCompose(true);

(I have tried with local compose set to false too)

Running a mvn goal that runs the tests, I get the following error:

WARN org.testcontainers.utility.ResourceReaper - Can not connect to Ryuk at 172.17.0.1:56047 java.net.ConnectException: Connection refused (Connection refused)

If I disable Ryuk I get errors stating that the port in use by a container is already bound. When I run a docker ps I can see the containers are already running. So it feels like there is lack of awareness between test containers and the docker sub system.

Once I am at the stage above with the Ryuk issue, I can run docker ps and see the container is running and the logs look ok. I can telnet etc the port Ryuk exposes and connectivity is there.

Also if I run docker-compose up against the docker compose file that the test uses everything works as expected. If I run the maven target on my local machine (Mac) it works ok. I have to run this in a container because of the CI in use.

Is there something I have missed or have I found a bug?

@Megaprog
Copy link

Have the same problem. It seems Testcontainers do not resolve hostname properly. It should be host.docker.internal:56047 address.

@pedromiranda-s4n
Copy link

Have the same problem. It seems Testcontainers do not resolve hostname properly. It should be host.docker.internal:56047 address.

I had same issue in MacOS (Docker Desktop 4.4.2 (73305), TestContainers 1.16.2). I tried setting environment variable TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal and it worked. Hope this helps!

@kiview
Copy link
Member

kiview commented Nov 30, 2022

@avst-dmartino sorry for not answering earlier, you are likely running into #4395. Please use the workaround from #4395 (comment) that was suggested to us by upstream Docker.

I'll close this issue as duplicate, please let us know if the issue persists.

@kiview kiview closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2022
@MikeLBook
Copy link

Have the same problem. It seems Testcontainers do not resolve hostname properly. It should be host.docker.internal:56047 address.

I had same issue in MacOS (Docker Desktop 4.4.2 (73305), TestContainers 1.16.2). I tried setting environment variable TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal and it worked. Hope this helps!

I could kiss you

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

No branches or pull requests

5 participants