Reputation: 1009
Say I have a docker compose file like this:
version: '2'
services:
randomDNStest:
dns:
- ###.###.###.###
network_mode: "host"
build: .
and a Dockerfile like this:
FROM gitlab/gitlab-runner
RUN ["gitlab-runner", "register", "--non-interactive", "--url", "THE INTERNAL GIT LAB INSTANCE", "--registration-token", "MY TOKEN", "--executor", "docker", "--tag-list", "docker", "--description", "DESCRIPTION", "--docker-image", "docker:19.03.1", "--docker-dns", "###.###.###.###", "--docker-privileged", "--docker-tlsverify", "--docker-volumes", "/certs/client"]
How can I specify the DNS server for the Dockerfile to use at build time (in the run command)?
docker run --dns
.
dns
section in docker-compose as shown above.
--dns-servers
parameter with the parameters described here
curl -X POST -F token=QytSH_88wASA_LA6G2mf --dns-servers ###.###.###.### https://INTERNAL_GIT_LAB//api/v4/runners
--dns-servers
command must be compiled in as described in the curl docs and in Nathan Leclaire's blog, but I couldn't get the dependencies right, and this only avoids using the problem for my specific use case.network_mode: "host"
driver as shown above and described here
Upvotes: 1
Views: 2334
Reputation: 158977
You do not want to run this command in your Dockerfile
. The basic concept there is that you can docker build
an image once, and then docker run
multiple copies of that container, or push the image to a registry and run it from other systems. A GitLab runner image that once upon a time has been registered with some particular server isn't especially useful to re-docker run
later on.
The GitLab documentation for this image suggests it isn't intended to be used as a base image at all. You can just put the command and other settings in your docker-compose.yml
file
version: '2'
services:
randomDNStest:
dns:
- ###.###.###.###
command: >-
register
--non-interactive
--url THE_INTERNAL_GITLAB_INSTANCE
...
(If this returns immediately, re-running docker-compose up
will repeat the command.)
Upvotes: 1