3

I am building my first docker install as part of learning django. I have my docker install working. docker info is ok. and hello-world says successfull. But when I run the Dockerfile suggested by the turorial in my Django 3.0 Pro Book by Will Vincent. I get what look like a network dns error.

################ Error:

    Step 6/7 : RUN pip install pipenv && pipenv install --system
 ---> Running in 585e5020f53a
    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 0x7f339144df10>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
   
 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 0x7f3391f05a90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
   
    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 0x7f3391f05e90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
    
    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 0x7f3391f05ad0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
    
    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 0x7f33915ddd90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
    
    ERROR: Could not find a version that satisfies the requirement pipenv (from versions: none)
    
    ERROR: No matching distribution found for pipenv
The command '/bin/sh -c pip install pipenv && pipenv install --system' returned a non-zero code: 1

####################

Dockerfile try to build:

Pull base image

FROM python:3.7

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set work directory
WORKDIR /code

# Install dependencies
COPY Pipfile Pipfile.lock /code/
RUN pip install pipenv && pipenv install --system

# Copy project
COPY . /code/

It is failing on the RUN pip install.... line.

I have added dns nameserver entries directly into my /etc/resolver.conf file as other have suggested in my search here. not worked.

I assume there is some issue within Docker trying to run pip in the container? This is my first Docker install so exhausted search for answer.

On OS version Centos8

Thanks bill sanderson

  • `systemctl restart docker` fixed the issue for me (reconfiguring docker network). – jfs Oct 12 '21 at 07:43

2 Answers2

8

Ok, we can try a couple of things. First thing I would do:

  • In the Dockerfile add this(with google's dns):

RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf && pip install pipenv && pipenv install --system

It is important to do in the same RUN command.

  • Another option is:

docker build --network=host -t yourimage:yourversion .

  • I had set my resolver to google 8.8.8.8... which did not work. I was able to run docker building --network=host which fix my build error. problem now is when i do docker-compose up. the same network error return as I have with docker buld.... when it tries to rebuild. i do not wee a network option on docker-compose... thanks – Bill Sanderson Jul 27 '20 at 17:38
  • Take a look at this: https://docs.docker.com/compose/networking/ – Claudio Lepin Jul 27 '20 at 19:01
  • 1
    But if you have so many troubles with your network config, maybe you should have to check your BIP docker setting in /etc/docker/daemon.json (put something like this to avoid networking conflicts): ```"bip" : "10.10.0.1/24"``` Another thing you can check is ```docker network ls``` and look for something weird, like another network in conflict. – Claudio Lepin Jul 27 '20 at 19:09
  • I dumped centos8 and installed ubuntu 20.04 LTS and went thru same docker setup. all is working now .... nothing special needed beyond same docker install instructions. thanks -- bill s. – – Bill Sanderson Jul 27 '20 at 21:54
0

I had the same issue last night - and this morning. Even after rebooting and trying to stop/start the service. This is on my Windows 10.

I did notice running a docker info output the following error:

Error response from daemon: open \\.\pipe\docker_engine_linux: The system cannot find the file specified

As detailed here - https://stackoverflow.com/a/74098179/405022

Having ran wsl --shutdown and being prompted to restart docker desktop, I then proceeded to try my docker build.

docker build -f ./sources/service1/deploy/dev.dockerfile ./sources/service1 -t acme-app.service1-py:latest --no-cache --progress=plain

Coincidence? It worked for me in the end.

Andez
  • 5,588
  • 20
  • 75
  • 116