Pip install 在 python Docker 镜像中冻结。但是在其他 Linux 机器上,它会立即启动。
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 390B 0.0s
=> [internal] load metadata for docker.io/library/python:3.11 1.1s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [1/7] FROM docker.io/library/python:3.11@sha256:58ef3c375e20ca749f5bf4d1a62186a01e9d1d5756671037e391c832a5062d1e 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 255.02kB 0.0s
=> CACHED [2/7] WORKDIR /code/src 0.0s
=> CACHED [3/7] COPY ./requirements.txt /code/requirements.txt 0.0s
=> CACHED [4/7] RUN pip install --no-cache-dir -U pip 0.0s
=> [5/7] RUN pip install --no-cache-dir --upgrade --default-timeout=5000 -r /code/requirements.txt 8377.6s
=> => # WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=5000.0)")': /s
=> => # imple/pydantic/
client_loop: send disconnect: Connection reset
有时它会在第 4 步失败并出现相同的警告。
Docker 文件:
FROM python:3.11
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /code/src
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir -U pip
RUN pip install --no-cache-dir --upgrade --default-timeout=5000 -r /code/requirements.txt
COPY ./ /code/src
ENV PYTHONPATH /code/src
RUN chmod a+x run.sh
CMD ["./run.sh"]
任何软件包安装都会导致冻结。没有 pip upgrade 和 pip install 的 Python docker 镜像可以正常工作。
我将非常感激任何建议。