Question or problem about Python programming:
I’m following the fig guide to using docker with a python application, but when docker gets up to the command
I get the following error message:
- FROM python:3.5.2-alpine RUN apk add -no-cache unixodbc-dev RUN pip install pyodbc.
- Pip install geopandas && pip install nnabla && pip install vowpalwabbit && # papermill can replace nbconvert for executing notebooks: pip install cloud-tpu-client && # b/188429515#comment7 tensorflow-cloud = 0.1.14 installs tensorflow-transform which install apache-beam which downgrades the google.cloud library to 1.x.
This repeats several times and then I get another message:
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 (blinker1.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.
Sep 11, 2021 Install a different version. $ docker run -net=container:http mohan08p/curl curl -s localhost Also, this container can see the interface with the processes in a shared container. $ docker run -pid=container:http alpine ps aux This will allow you give more privileges to containers without changing or restarting the application.
Does anyone have any idea what’s going on here?
Pip Install Inside Docker Container
How to solve the problem:
Pip Install Inside Docker Download
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
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 126.96.36.199, 188.8.131.52;
Restart dhclient :
$ sudo dhclient.
2. Modifying Docker config
As explained in the docs :
Systems that run Ubuntu or an Ubuntu derivative on the desktop typically use 127.0.0.1 as the default nameserver in /etc/resolv.conf file.
To specify a DNS server for use by Docker :
3. Using a parameter when you run Docker
When you run docker, simply add the following parameter :
I needed to add –network=host to my docker build command:
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:
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
ok, restarting my docker-machine is solving the problem. thanks – ismailsunni
This was the solution for me:
For me simply restarting docker daemon helped.
For Ubuntu users
You need to add new DNS addresses in the docker config
Add the dns after ExecStar.
Should look like that:
In my case, with
docker version 1.13.0 and
docker-machine 0.9.0 under
Ubuntu 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 :
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
- Checking the inet addr of your ethernet or wlan in
- Choosing any address in
nmcli dev show grep 'DNS'
- Checking the inet addr of your ethernet or wlan in
Edit dns in
/etc/docker/daemon.json(create this file if it doesn’t exist previously)
sudo service docker restart
In case someone is reading this using docker-compose. I managed to resolve this by changing my yaml file as follows
which is equivalent to writing
As a Docker newbie, I had a problem that manifested itself in this way when I was following the tutorial for Docker at:
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.