Issue
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...
class="lang-sh prettyprint-override">(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?
Solution
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.
- Read the host
/etc/resolv.config
(Yours will likely be different)
$ cat /etc/resolv.config
# Generated by expressvpn
search expressvpn
nameserver 10.53.0.1
- Make a new, or use the
/etc/docker/daemon.json
(I had to use Super User to write the file)
$ sudo touch /etc/docker/daemon.json
- Use the Daemon file to manually set the Virtual Network to the host
/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.
{
"dns": [
"10.53.0.1"
],
"dns-search": [
"expressvpn"
]
}
- Hard stop all docker processing
$ sudo ps axf | grep docker | grep -v grep | awk '{print "kill -9 " $1}' | sudo sh
- Restart Docker Daemon
$ sudo dockerd
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.
Answered By - VolksRat71 Answer Checked By - Pedro (WPSolving Volunteer)