I have the following configuration in .gitlab-ci.yml
file:
image: docker:20.10.16
# When using dind, it's wise to use the overlayfs driver for
# improved performance.
variables:
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_DRIVER: overlay2
services:
- docker:20.10.16-dind
pages:
stage: deploy
before_script:
- 'command -v ssh-agent >/dev/null || ( apk add --update openssh )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $REPO_IPADDRESS >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- docker info
script:
- docker --version
- docker-compose -f docker-compose.prod.yaml up -d
artifacts:
paths:
- public
only:
- main
How can I set nameserver for my gitlab-runner or make it use the nameserver of the OS that it is running on?
use the nameserver of the OS that it is running on
That should be the default behavior and, in my experience, also works with GitLab's docker-in-docker without any additional configuration -- lookups get forwarded to the host's DNS servers. Per the docker docs:
By default, containers inherit the DNS settings of the host, as defined in the
/etc/resolv.conf
configuration file. Containers that attach to the defaultbridge
network receive a copy of this file. Containers that attach to a custom network use Docker’s embedded DNS server. The embedded DNS server forwards external DNS lookups to the DNS servers configured on the host.
But in any case, you can explicitly configure DNS for containers that the GitLab docker runner manages with the dns
and search_dns
options in the [runners.docker]
section configuration.