I am attempting to write Dockerfile
instructions to use yum
and install a few packages. When I run my build command, I will always get an error…
(28, 'Resolving timed out after 5000 milliseconds')
… due to the lack of network access. I have compared my host and container /etc/resolv.conf
, and noticed they were different.
Example (Host)
# Generated by expressvpn
search expressvpn
nameserver 10.53.0.1
Example (Container)
search expressvpn
nameserver 10.1.2.3
nameserver 8.8.8.8
I attempted copying the host /etc/resolv.conf
and overwriting the container /etc/resolv.conf
as follows
$ echo "# Generated by expressvpn
> search expressvpn
> nameserver 10.53.0.1" > "/etc/resolv.conf"
Then immediately gained network access again and was able to use yum
. However, if I try reading the Dockerfile
with a build command, it does not seem to work anymore. How do I make docker use the host resolv.conf
on build or resolve this issue correctly? It seemed to not have an issue with my VPN before. Is that the issue now?
2
Answers
I was able to at least get my docker to build the containers by taking the same naming conventions used in the Docker Daemon CLI options and applying them to a
/etc/docker/daemon.json
manually, then restarting the Docker Daemon./etc/resolv.config
(Yours will likely be different)/etc/docker/daemon.json
(I had to use Super User to write the file)/etc/resolv.conf
output as described in #1 (Again yours is likely to be different). You can find the different options here just use the CLI options as keys and arrays with strings as values.This is not the most elegant solution, but I was able to at least get my Docker to build the Container and continue on with my work.
Docker overrides the
resolve.conf
file so it matches the virtual network it is setting up. You may have an atypical network setup for your container that is screwing up Docker. There are two ways to automate the fix you came up with above:--dns
option in the command line should tell Docker how to properly create the resolve file how you want it.You can also try to figure out why Docker is getting screwed up, but that is a potentially much more complicated problem.