Gitlab is setup on our internal network at http://gitlab
Docker containers on the same machine can't connect to it.
How do I configure docker so that it knows gitlab is its parent?
The problem exhibits itself when Gitlab CI attempts to run a build (inside a Docker container):
Cloning into '/builds/ns/project'... fatal: unable to access 'http://gitlab-ci-token:xxxxxx@gitlab/ns/project.git/': Couldn't resolve host 'gitlab'
I've tried adding the network's DNS servers to DOCKER_OPTS
in /etc/default/docker
to no avail.
According to the GitLab CI Runner Advanced configuration, you can try to play with the extra_hosts
param in your GitLab CI runner.
In /etc/gitlab-runner/config.toml
:
[[runners]]
url = "http://gitlab/ci"
token = "TOKEN"
name = "my_runner"
executor = "docker"
[runners.docker]
host = "tcp://<DOCKER_DAEMON_IP>:2375"
image = "..."
...
extra_hosts = ["gitlab:192.168.0.39"]
With this example, when inside the container running the test git will try to clone from gitlab, it will use the 192.168.0.39
as IP for this hostname.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With