I'm following the fig guide to using docker with a python application, but when docker gets up to the command
RUN pip install -r requirements.txt
I get the following error message:
Step 3 : RUN pip install -r requirements.txt
---> Running in fe0b84217ad1
Collecting blinker==1.3 (from -r requirements.txt (line 1))
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', gaierror(-2, 'Name or service not known'))': /simple/blinker/
This repeats several times and then I get another message:
Could not find any downloads that satisfy the requirement blinker==1.3 (from -r requirements.txt (line 1))
No distributions at all found for blinker==1.3 (from -r requirements.txt (line 1))
So for some reason pip can't access any packages from inside a docker container. Is there anything I need to do to allow it internet access?
However pip works fine to install things outside of the docker container, and worked fine even with that exact package (blinker==1.3
) so that's not the problem. Also this problem isn't specific to that package. I get the same issue with any pip install
command for any package.
Does anyone have any idea what's going on here?
In my case, with
docker version 1.13.0
anddocker-machine 0.9.0
underUbuntu 16.04
I had to modify slightly Tanzaho's answer (2. Modifying Docker config) as follows:Log into Ubuntu as a user with sudo privileges.
Open the /etc/default/docker file for editing:
Add the following setting for Docker.
Save and close the file.
Restart the Docker daemon :
Your problem comes from the fact that Docker is not using the proper DNS server. You can fix it in three different ways :
1. Adding Google DNS to your local config
Modifying /etc/resolv.conf and adding the following lines at the end
# Google IPv4 nameservers nameserver 8.8.8.8 nameserver 8.8.4.4
If you want to add other DNS servers, have a look here.
However this change won't be permanent (see this thread). To make it permanent :
$ sudo nano /etc/dhcp/dhclient.conf
Uncomment and edit the line with prepend domain-name-server :prepend domain-name-servers 8.8.8.8, 8.8.4.4;
Restart dhclient :
$ sudo dhclient
.2. Modifying Docker config
As explained in the docs :
3. Using a parameter when you run Docker
When you run docker, simply add the following parameter :
--dns 8.8.8.8
I had same problem.The cause of error is proxy.
So, I edit Dockerfile following
For me, it was caused by being connected to my university VPN. Disconnecting "solved" the problem.
For me, I was unable to install pip due to the docker's DNS not configured properly. I've tried the above steps, however, configuring docker DNS to Google DNS does not work for my laptop. Docker's DNS can be properly configured only if I set its DNS to my laptop's assigned IP.
If you use Ubuntu, you can use the following steps to configure your docker's DNS:
Find out your device's assigned IP. You can find this by either
ifconfig
nmcli dev list | grep 'DNS'
Change dns in
/etc/docker/daemon.json
sudo service docker restart
I do not know the reason, but the error means that pip is trying to resolve the
/simple/blinker/
as a DNS hostname instead of thepypi.python.org
part, which seems very odd since I cannot even come up with any URL for whichurlparse
could return such a string as a hostname part. I'd check if there is some problem with~/.pip/pip.conf