【发布时间】:2022-01-11 16:42:35
【问题描述】:
我一直在使用 Docker 和 pipenv 进行数据科学部署设置,现在我想改用 Poetry。我的 Dockerfile 是:
FROM python:3.8-alpine3.13
ENV POETRY_VIRTUALENVS_CREATE=false \
POETRY_VERSION=1.1.11
RUN apk add --no-cache python3-dev gcc libc-dev musl-dev openblas gfortran build-base postgresql-libs postgresql-dev libffi-dev \
&& pip install poetry
COPY pyproject.toml poetry.lock ./
RUN poetry export -f requirements.txt --output requirements.txt && sed -i 's/^-e //' requirements.txt
USER root
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev gcc libc-dev musl-dev openssh-client git libpq-dev \
&& apt-get clean -y
# install dependencies from requirements.txt
RUN pip install --no-cache-dir --user -r requirements.txt
COPY . .
CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
我的pyproject.toml:
[tool.poetry]
name = ""
version = "1.0.0"
description = ""
authors = [""]
[tool.poetry.dependencies]
python = "^3.8"
... # lots of libraries, omitted here
[tool.poetry.dev-dependencies]
black = "*"
ipykernel = "6.*"
ipython = "7.*"
isort = "5.*"
jupyter = "*"
pytest = "6.*"
pre-commit = "2.*"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
这是基于我在 StackOverflow 上找到的其他 Dockerfile。我遇到了以下问题:
Step 7/10 : RUN apt-get update && apt-get install -y --no-install-recommends python3-dev gcc libc-dev musl-dev openssh-client git libpq-dev && apt-get clean -y
---> Running in 447ffb83d555
/bin/sh: apt-get: not found
The command '/bin/sh -c apt-get update && apt-get install -y --no-install-recommends python3-dev gcc libc-dev musl-dev openssh-client git libpq-dev && apt-get clean -y' returned a non-zero code: 127
Running containerdocker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "jupyter": executable file not found in $PATH: unknown.
ERRO[0000] error waiting for container: context canceled
make: *** [Makefile:6: jupyter_notebook] Error 127
所以这看起来像没有使用 Poetry,安装了 Jupyter,因此找不到它。我该如何解决这个问题?
【问题讨论】:
-
为什么不从现有的 jupyter 图像开始?
-
@OneCricketeer 因为它们包含很多包,我不需要其中的一半
标签: python linux docker python-venv python-poetry