Temporary failure in name resolution [Errno -3] wi

2020-05-20 07:41发布

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!

9条回答
姐就是有狂的资本
2楼-- · 2020-05-20 07:54

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:

  1. You can specify a DNS server for Docker to use, or
  2. You can disable dnsmasq in NetworkManager. If you do this, NetworkManager will add your true DNS nameserver to /etc/resolv.conf, but you will lose the possible benefits of dnsmasq. You only need to use one of these methods.

you can read about how to perform these steps here

查看更多
Ridiculous、
3楼-- · 2020-05-20 07:57

for me rebooting host machine resolved the issue

查看更多
\"骚年 ilove
4楼-- · 2020-05-20 08:00

I got the same problem with Ubuntu 16.04 and Docker version 17.09.0-ce. I don't think disabling dns mask 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: Docker - Network calls fail during image build on corporate network

查看更多
你好瞎i
5楼-- · 2020-05-20 08:01

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

{
    "dns": ["8.8.8.8", "8.8.4.4"]
}

Don't forget to

sudo service docker restart
查看更多
走好不送
6楼-- · 2020-05-20 08:02

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.

查看更多
Root(大扎)
7楼-- · 2020-05-20 08:06

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

查看更多
登录 后发表回答