'No network request working from a docker when building docker image
I'm trying to build docker image with Dockerfile. For the experiment, I added to this file such lines:
RUN ping google.com
RUN ping 8.8.8.8
Then I'm trying to build this image:
docker build -t my-custom-python:latest -f ./Dockerfile
And this code not working properly. For ping commands it says:
ping: bad address 'google.com'
If I remove this lines, then it executes command:
RUN pip wheel --wheel-dir=/wheels -r /requirements/dev.txt
it reads my requiremets/dev.txt file, sees such line:
git+git://github.com/bpython/bpython.git
And after this it says:
Running command git clone -q git://github.com/bpython/bpython.git /tmp/pip-req-build-o8c7n380 fatal: unable to look up github.com (port 9418) (Try again) ERROR: Command errored out with exit status 128: git clone -q git://github.com/bpython/bpython.git /tmp/pip-req-build-o8c7n380 Check the logs for full command output.
It seems there is a problem with DNS, and (as I noticed) it started when I install ExpressVPN. But in my host machine ping and git clone works.
I also tried to disable VPN - nothing changes. I don't know how to ckeck if DNS works insight Docker or how to fix it.
Please, need your help!
Solution 1:[1]
This post was very helpfull for me: My docker container has no internet
I changed resolv.conf on my host machine (Ubuntu 18.04):
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
And after this, I recreated Docker configs:
pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d
Now, everything works fine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
