Docker Community Forums

Share and learn in the Docker community.

Python Error reported by docker using pip to install requirements files

my dockerfile is write:

FROM python:3.6
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
CMD scrapy crawl country

error is :
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.HTTPConnection object at 0x7ffaf52ff898>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution’,)’: /simple/pymysql/

requirements.txt is Under my project root path, all are ready

I don’t know how to solve it. I hope you can help me. Thank you

1 Like

@zzaa5858 were you able to figure out? I’m having the same issue when trying to do docker build from VS Code for an django app. I’ve seen posts about this being proxy issue, but I’ve verified that my machine is not using any proxy. Here is my details:

Dockerfile:

FROM python:3.8
EXPOSE 8000
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ADD requirements.txt .
RUN python -m pip install -r requirements.txt
WORKDIR /app
ADD . /app
RUN useradd appuser && chown -R appuser /app
USER appuser
CMD [“gunicorn”, “–bind”, “0.0.0.0:8000”, “helloworld.wsgi”]

Log:

Step 6/12 : RUN python -m pip install -r requirements.txt
—> Running in da3e67506ace
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000256DED38CA0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed’)’: /simple/django/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000256DED38640>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed’)’: /simple/django/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000256DED38B80>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed’)’: /simple/django/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000256DED29880>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed’)’: /simple/django/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x00000256DED296D0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed’)’: /simple/django/
ERROR: Could not find a version that satisfies the requirement django==3.0.3 (from -r requirements.txt (line 2)) (from versions: none)
ERROR: No matching distribution found for django==3.0.3 (from -r requirements.txt (line 2))
The command ‘powershell -Command $ErrorActionPreference = ‘Stop’; $ProgressPreference = ‘SilentlyContinue’; python -m pip install -r requirements.txt’ returned a non-zero code: 1
The terminal process terminated with exit code: 1

@ronnieliu

Even I faced the same issue, after spending two days of debugging found a working solution.

My System Info :
Dev VM based on Centos 7

Solution :
Please connect with IT team to get the list of supported DNS Server for your system

Step 1:
Update the files /etc/resolv.conf and /etc/docker/daemon.json with the format as below
Step 3 : Ensure firewall is running. For me when i disable firewall then i see the error again
service firewalld start
service firewalld status
Step 3: Reboot the system

Files Info

cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver YOUR_ORG_DNS_IP_1
nameserver YOUR_ORG_DNS_IP_2
nameserver YOUR_ORG_DNS_IP_3

cat /etc/docker/daemon.json
{
“dns”: [“8.8.4.4”, “8.8.8.8”, “YOUR_ORG_DNS_IP_1”, “YOUR_ORG_DNS_IP_2”, “YOUR_ORG_DNS_IP_3”],
“ipv6”: false
}