DockerInDocker: pip install fails on docker image build

7/8/2020

I'm working on a Kubernetes cluster with Istio installed, and I'm using the docker:dind image on a pod to dynamically build docker images. The problem is as soon as the building phase reaches the RUN pip install numpy of my Dockerfile it fails throwing the following error:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/numpy/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/numpy/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/numpy/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/numpy/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/numpy/
ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy

The Dockerfile for testing:

FROM python:3.7.7-slim-buster

RUN pip install numpy

CMD ["echo", "Testing..."]

The pod that contains the docker:dind image is able to install Python packages, executing:

/ # apk add python3 py3-pip
/ # pip install numpy
Collecting numpy
  Downloading numpy-1.19.0.zip (7.3 MB)
     |████████████████████████████████| 7.3 MB 1.4 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  ...

works (actually fails due to build dependencies, but it can connect to pypi), but doing something like:

/ # cd tmp/
/ # vi Dockerfile # Set the content as described above
/ # docker build .
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM python:3.7.7-slim-buster
3.7.7-slim-buster: Pulling from library/python
8559a31e96f4: Pull complete 
62e60f3ef11e: Pull complete 
286adfd1ee25: Pull complete 
8973789a3a6b: Pull complete 
9b8d369425a7: Pull complete 
Digest: sha256:5b25848c082804c500e8cadce6d1b344791aa39d82cb9d56285c65e3e937f0c2
Status: Downloaded newer image for python:3.7.7-slim-buster
 ---> 4cbd5021babc
Step 2/3 : RUN pip install numpy
 ---> Running in 0496b1cfcbb0
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/numpy/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/numpy/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/numpy/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/numpy/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/numpy/
ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy

simply fails...

I'd like to know if someone has encountered with something like this and been able to solve it.

Thanks in advance. :)

-- I. Ortega
docker-in-docker
istio
kubernetes
pip

0 Answers