Docker构建最后一步失败,但交互式Shell执行相同命令成功
poetry install --no-root执行失败,交互式Shell中执行成功 在CentOS 7服务器上使用预装的Podman构建镜像时,最后一步执行RUN poetry install --no-root报错(退出状态1),但运行最后成功步骤生成的镜像并进入交互式Shell执行相同命令却能成功,该问题疑似与Buildah的资源限制类问题相关。
Dockerfile内容
FROM python:3.10.6 RUN apt update RUN apt -y upgrade RUN apt search golang-go RUN apt install -y golang-go # expose streamlit port EXPOSE 8501 # working dir is /app WORKDIR /app ENV PYTHONPATH=/app # Install virtual environment RUN pip install poetry COPY ./pyproject.toml /app RUN poetry config virtualenvs.create false RUN poetry install --no-root
pyproject.toml内容
[tool.poetry] version = "0.1.0" description = "" readme = "README.md" [tool.pytest.ini_options] log_cli = true log_cli_level = "INFO" log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)" log_cli_date_format = "%Y-%m-%d %H:%M:%S" [tool.poetry.dependencies] torch = [{markers = "sys_platform == 'macos'", url = "https://download.pytorch.org/whl/cpu/torch-1.13.0-cp310-none-macosx_11_0_arm64.whl"}, {markers = "sys_platform == 'linux' and platform_machine == 'arm64'", url="https://download.pytorch.org/whl/torch-1.13.0-cp310-cp310-manylinux2014_aarch64.whl"}, {markers = "sys_platform == 'linux' and platform_machine == 'x86_64'", url="https://download.pytorch.org/whl/cpu/torch-1.13.0%2Bcpu-cp310-cp310-linux_x86_64.whl"}] python = "^3.10" pytest = "^7.2.0" toml = "^0.10.2" scikit-learn = "^1.1.3" scikit-optimize = "^0.9.0" ax-platform = "^0.2.8" setuptools = "^65.5.1" fire = "^0.4.0" jupyter = "^1.0.0" streamlit-ace = "^0.1.1" humanfriendly = "^10.0" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"
构建时错误信息
Writing lock file
Package operations: 126 installs, 1 update, 0 removals
error building at step {Env:[PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin LANG=C.UTF-8 GPG_KEY=A035C8C19219BA821ECEA86B64E628F8D684696D PYTHON_VERSION=3.10.6 PYTHON_PIP_VERSION=22.2.1 PYTHON_SETUPTOOLS_VERSION=63.2.0 PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/5eaac1050023df1f5c98b173b248c260023f2278/public/get-pip.py PYTHON_GET_PIP_SHA256=5aefe6ade911d997af080b315ebcb7f882212d070465df544e1175ac2be519b4 PYTHONPATH=/app] Command:run Args:[poetry install --no-root] Flags:[] Attrs:map[] Message:RUN poetry install --no-root Original:RUN poetry install --no-root}: error while running runtime: exit status 1
补充现象
进入镜像的交互式Shell执行poetry install --no-root无报错,且成功安装了对应版本的torch:
• Installing torch (1.13.0+cpu https://download.pytorch.org/whl/cpu/torch-1.13.0%2Bcpu-cp310-cp310-linux_x86_64.whl)
内容的提问来源于stack exchange,提问作者Hanan Shteingart

