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?
I had the same issue and it plagued me for a while and I tried a lot of solutions online but to no avail. However I finally resolved it as follows:
Running:
Discover the address of your DNS server.
Discover the address of your DNS server by running the following command:
Update the Docker daemon
Create a docker config file at
/etc/docker/daemon.json.
(if you don't already have one) and add the following content to the file:The first item of the array is your network's DNS server and the second is google's DNS server as a fallback when if your network's DNS is not available.
Save the file and then restart the docker service
As a Docker newbie, I had a problem that manifested itself in this way when I was following the tutorial for Docker at:
https://docs.docker.com/get-started/part2
I'm using Docker 17.03.1-ce on a corporate LAN.
I checked and double checked my DNS settings. I'd used various ways of configuring the DNS that I'd found in my searches across the Internet. Some caused errors on startup. The approach that I ultimately settled upon for configuring the DNS was the one in the Troubleshoot Linux section of the above link above where the DNS is configured via the daemon.json file in the /etc/docker directory.
However, I still had this same issue. What finally solved the problem for me was the configuration of the proxy via the http_proxy and https_proxy environment variables. I had them specified in my Dockerfile, but I neglected to do so before the RUN pip command.
Even though it appeared to be a DNS issue, moving these ENV commands ahead of the RUN command made the difference for me. In case that is helpful for anyone with this problem.