DockerInDocker:在Docker映像构建中pip安装失败

时间:2020-07-08 20:16:31

标签: kubernetes pip istio docker-in-docker

我正在安装Istio的Kubernetes集群上工作,并且我在Pod上使用docker:dind映像来动态构建docker映像。问题是,一旦构建阶段达到我的Dockerfile的RUN pip install numpy,它就会失败并引发以下错误:

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

用于测试的Dockerfile:

FROM python:3.7.7-slim-buster

RUN pip install numpy

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

包含docker:dind映像的容器可以执行以下操作来安装Python软件包:

/ # 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
  ...

可以工作(实际上由于构建依赖项而失败,但是它可以连接到pypi ),但是可以执行以下操作:

/ # 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

完全失败...

我想知道是否有人遇到过这样的事情并且能够解决它。

先谢谢了。 :)

0 个答案:

没有答案