You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
@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.
This workaround worked for us in github runner (it works well with ryuk being enabled):
from testcontainers.core.container import DockerContainer
def fixed_get_container_host_ip(self) -> str:
host = self.get_docker_client().host() or "localhost"
if inside_container() and not os.getenv("DOCKER_HOST") and not host.startswith("http://"):
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
return host
DockerContainer.get_container_host_ip = fixed_get_container_host_ip
# run your testcontainer afterwards
Activity
alexanderankin commentedon Jul 10, 2024
am planning on fixing in #622
tholu commentedon Jul 16, 2024
This should also come with documentation on how to setup a working CI pipeline on Gitlab and Github.
alexanderankin commentedon Jul 16, 2024
meiswjn commentedon 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 commentedon Jul 31, 2024
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 commentedon 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 commentedon Aug 6, 2024
For me, it works like this (in a Gitlab Runner):
malltshik commentedon Sep 10, 2024
This workaround worked for us in github runner (it works well with ryuk being enabled):
kiview commentedon Oct 15, 2024
As @asafm reported in Slack, starting the container in Docker-Wormhole-Pattern mode with host network seems to work: