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

Bug: Testcontainers in Docker container #644

Open
joeg-ita opened this issue Jul 10, 2024 · 7 comments
Open

Bug: Testcontainers in Docker container #644

joeg-ita opened this issue Jul 10, 2024 · 7 comments

Comments

@joeg-ita
Copy link

method get_container_host_ip(self) in testcontainers/core/container.py

have the following code commented (you drive me crazy) and should be uncommented

    # # check testcontainers itself runs inside docker container
    # if inside_container() and not os.getenv("DOCKER_HOST") and not host.startswith("http://"):
    #     # If newly spawned container's gateway IP address from the docker
    #     # "bridge" network is equal to detected host address, we should use
    #     # container IP address, otherwise fall back to detected host
    #     # address. Even it's inside container, we need to double check,
    #     # because docker host might be set to docker:dind, usually in CI/CD environment
    #     gateway_ip = self.get_docker_client().gateway_ip(self._container.id)

    #     if gateway_ip == host:
    #         return self.get_docker_client().bridge_ip(self._container.id)
    #     return gateway_ip
@alexanderankin
Copy link
Collaborator

am planning on fixing in #622

@tholu
Copy link

tholu commented Jul 16, 2024

This should also come with documentation on how to setup a working CI pipeline on Gitlab and Github.

@alexanderankin
Copy link
Collaborator

alexanderankin commented Jul 16, 2024 via email

@meiswjn
Copy link
Contributor

meiswjn commented Jul 31, 2024

It looks like this was introduced in #388
@kiview this change sadly broke our setup I think - can't we find a way to support both?

It essentially prevents all docker in docker use cases from what I see.

@mkemmerz
Copy link

We were impacted by this as well, costed us almost 2 days 👎
Solution was to go back to testcontainers 3.7.*, not a nice solution but it works at least.

@gaby
Copy link

gaby commented Aug 6, 2024

@alexanderankin We are not using "dind" on a private hosted GitLab/Runner and it still doesnt work. Our runner does run in Docker, with "host" network and "/var/run/docker.sock" access. This used to work fine in v3.x hasnt work since 4.x.

I'm also using testcontainers-go, and that one works fine, it's something with this package.

@tholu
Copy link

tholu commented Aug 6, 2024

For me, it works like this (in a Gitlab Runner):

my-job:
  variables:
    TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: "/var/run/docker.sock"
    TESTCONTAINERS_RYUK_DISABLED: true

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

No branches or pull requests

6 participants