[Bug]: Running on gitlab CI does not work as host.docker.internal is not available
Module
Core
Testcontainers version
1.17.2
Using the latest Testcontainers version?
Yes
Docker version
Docker version 20.10.17, build 100c701
What happened?
The docs for gitlab CI show a wrong config.toml. On linux the host.docker.internal is not reachable.
Test ist with
ping:
stage: test
script: apt update; apt install -y iputils-ping; ping -c1 host.docker.internal
The result is:
...
Setting up iputils-ping (3:20210202-1) ...
ping: host.docker.internal: Name or service not known
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1
...
I found some information about host.docker.internal on linux machines: https://medium.com/@TimvanBaarsen/how-to-connect-to-the-docker-host-from-inside-a-docker-container-112b4c71bc66
I added extra_hosts=["host.docker.internal:host-gateway"] to my config.toml and no the server is reachable
The documentation should add this.
Relevant log output
Setting up iputils-ping (3:20210202-1) ...
ping: host.docker.internal: Name or service not known
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1
Additional Information
No response
From the docker documentation
We recommend that you connect to the special DNS name host.docker.internal which resolves to the internal IP address used by the host. This is for development purpose and does not work in a production environment outside of Docker Desktop.
I can't find which docker version is needed for host-gateway to work, this was added sometime last year .
It doesn't work on my Ubuntu 18.04 (Docker version 20.10.17) so I ended up using extra_hosts=["host.docker.internal:172.17.0.1"] in the runner's config.toml, where 172.17.0.1 is the IP address of the docker0 interface.