Reputation: 1811
I'm following the docker tutorial and am on the part where I have to build the app using:
docker build -t friendlyhello .
It reaches up to step 4, where after a pause I get this error:
Step 4/7 : RUN pip install -r requirements.txt
---> Running in 7f4635a7510a
Collecting Flask (from -r requirements.txt (line 1))
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after
connection broken by
'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection
object at 0x7fe3984d9b10>: Failed to establish a new connection:
[Errno -3] Temporary failure in name resolution',)': /simple/flask/
I'm not quite sure what this error means and how I can go about solving it.
Thanks for your help!
Upvotes: 104
Views: 190476
Reputation: 4669
docker
or docker-compose.yml
!In my case, I was running a rabbitmq instance via a compose file, like so:
services:
rabbitmq:
image: rabbitmq:latest
ports:
- 5672:5672
- 15672:15672
postgres:
# ...
myapplication:
# ...
environment:
- BROKER_URL=amqp://guest:guest@rabbitmq:5672
In that compose are 2 other services, including the app itself, which is normally deployed to a container service via this compose file. However, while developing locally in Pycharm, I found it easier to just spin up the rabbitmq and postgres services and develop the app locally.
Note that the environment variable for BROKER_URL
references the rabbitmq service via its docker service name (rabbitmq
). When I pulled that var out to use with the locally running application (via a .env
file), I failed to replace it with localhost
, since docker is no longer doing the name resolution for me. Fixing that fixed the parent issue for me.
Check for similar problems in your config!
Upvotes: 0
Reputation: 498
bkasap's answer changes a system's feature I would say is exaggerated. Further because there are options in docker to do that. The new way to do that is
$ sudo vi /etc/docker/daemon.json
and add following content and modify it if necessary with your dns setup.
{
"dns": ["8.8.8.8", "8.8.4.4"]
}
Don't forget to
sudo service docker restart
Upvotes: 38
Reputation: 138
For some reason, I disabled iptables
in the daemon.json
. Removing that helped me to get my image build.
Upvotes: 0
Reputation: 7925
I was using "Cisco AnyConnect" as a VPN client on Ubuntu. It was disconnecting every time a URL had to be resolved.
I ended up using another VPN client.
Upvotes: 0
Reputation: 139
Thats the solution that worked for me:
Just executed docker network list
and tested with the differents networks on the docker build --network=XXX .
. The one that worked was host
.
Upvotes: 2
Reputation: 207
I changed the default DNS server in /etc/resolv.conf
and it worked for me.
FROM:
nameserver 127.0.0.53
options edns0 trust-ad
TO:
nameserver 8.8.8.8
#nameserver 127.0.0.53
options edns0 trust-ad
I just added the DNS server of Google and commented out the default DNS server.
Upvotes: 3
Reputation: 1488
Don't forget to check your internet connection especially if you are using a virtual machine in cloud (for example EC2).
I had no internet connection when I tried to run a container in the EC2. I was connected by bastion host to the VM. I didn't have internet connection for the virtual machine.
I wasted too much time. I hope this answer helps the people like me.
Upvotes: 0
Reputation: 1086
If you are facing it on windows machine,you can configure the way docker containers interact with network and set dns manually. Settings=>Resources=>Network=>Manual DNS Configuration Here is how it is configured
Upvotes: 0
Reputation: 2712
My case was tricky and related to environmental conditions, but is worth mentioning. I was under a firewall with bandwidth limitations based on its own hierarchy-based logic (critical, hard, medium traffic, etc...).
Every time I was starting huge docker pull, everything on my host started misbehaving (https browser navigation based upon DNS, ping based upon DNS, ... and Docker, ofc.
Removing those limits fixed my problem, so check your network, too.
Upvotes: 0
Reputation: 2221
I got the same problem with Ubuntu 16.04 and Docker version 17.09.0-ce.
I don't think disabling dnsmasq
is the right solution.
Here is how I solved it:
For Ubuntu
Edit /etc/default/docker and add your DNS server to the following line:
Example
DOCKER_OPTS="--dns 8.8.8.8 --dns 10.252.252.252"
Reference: Network calls fail during image build on corporate network
Upvotes: 38
Reputation: 1881
Had this just now, on my Ubuntu 20.04. Randomly, it just stopped working!
Tried:
sudo service network-manager restart
Did not work. Then I just did:
sudo systemctl restart docker
and the issue was resolved!
Upvotes: 16
Reputation: 258
I also got the "temporary failure in name resolution" too. My solution was to specify the network on the docker build command:
s001# docker network create example_net
s001# docker build --network example_net -t example_image example_image
^^^^^^^^^^^^^^^^^^^
I also configured the dns on docker config on my development notebook:
s001# nano /etc/docker/daemon.json
{
"dns": ["8.8.8.8"]
}
s001# systemctl restart docker
Upvotes: 2
Reputation: 190
On fedora 32 it was problem with firewall. Following command resolved issue:
$firewall-cmd --permanent --zone=trusted --add-interface=docker0
$firewall-cmd --reload
Upvotes: 19
Reputation: 25107
I had this problem on Windows 10 Pro and I solved it by right clicking on the docker icon in the tray and choosing "Restart...". It took a few mins and then the network was running fine again.
Upvotes: 2
Reputation: 1276
I just did sudo service docker restart
and it worked after. Definitely worth a shot before jumping in to modify your configurations.
Upvotes: 105
Reputation: 161
this post worked for me too!
Solved by dns mask [sic] disable:
sudo vim /etc/NetworkManager/NetworkManager.conf
comment out dns=dnsmasq -> #dns=dnsmasq
sudo service network-manager restart (or reboot VM in this case)
from: https://github.com/moby/moby/issues/26330
Upvotes: 16
Reputation: 460
It's silly, but I had a VPN connected when I got this error.
After disconnecting the VPN, PIP started working again.
Upvotes: 26
Reputation: 446
I am having the same issue with Ubuntu 16.04.1 machine for docker-ce 17. Its got fixed by disable the dns mask in the network.
sudo nano /etc/NetworkManager/NetworkManager.conf
Press Ctrl+O save and Enter the exit Ctrl+X
Restart the network service by running bellow command.
sudo service network-manager restart
After this if you run the docker build command everything will work fine.
Upvotes: 5
Reputation: 985
This error means your Docker container is unable to access your network. Beginning with systemd version 220, the forwarding setting for a given network (net.ipv4.conf..forwarding) defaults to off. This setting prevents IP forwarding. It also conflicts with Docker’s behavior of enabling the net.ipv4.conf.all.forwarding setting within containers.
If your container needs to resolve hosts which are internal to your network, the public nameservers will not be adequate. You have two choices:
you can read about how to perform these steps here
Upvotes: 8