Poetry install 在构建 Docker 镜像时抛出“连接池已满,正在丢弃连接:pypi.org。连接池大小:10”错误

gru*_*mli 13 pypi docker python-poetry

我无法构建我的 docker 镜像。通过 Poetry 安装依赖项时,它会抛出“连接已满”错误。在我的主机上不会发生这种情况。我该如何解决这个问题。我需要增加池大小吗?如果是,怎么办?

我的 Dockerfile

FROM python:3.10-alpine AS python
ENV PYTHONUNBUFFERED=true
WORKDIR /app

FROM python as poetry
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
ENV PATH="$POETRY_HOME/bin:$PATH"
RUN python -c 'from urllib.request import urlopen; print(urlopen("https://install.python-poetry.org").read().decode())' | python -
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-interaction --no-ansi -vvv
Run Code Online (Sandbox Code Playgroud)

小智 29

在我的项目中使用 Dockerfile,我在最后一行之前添加了一行,如下所示:

RUN poetry config installer.max-workers 10

RUN poetry install --no-interaction --no-ansi -vvv
Run Code Online (Sandbox Code Playgroud)

这对我有用!