复制文件 - 在 Dockerfile 旁边 - 不起作用并阻止 docker 构建
COPY files - next to Dockerfile - don't work and block docker build
我正在尝试构建一个 docker 容器,其中包含 mlflow 服务器,并使用 poetry toml 文件进行依赖。(这两个 toml 完全相同,这只是一种尝试弄清楚的方法)
树:
├── docker-entrypoint.sh
├── Dockerfile
├── 文件
│ └── pyproject.toml
├── git.sh
├── pyproject.toml
└── README.md
如你所见,我的 toml 文件在 Dockerfile 旁边 COPY pyproject.toml ./
不过还是不行
Dockerfile
FROM python:3.6.10-alpine3.10 as base
LABEL maintainer=""
ENV PYTHONFAULTHANDLER 1
ENV PYTHONHASHSEED random
ENV PYTHONUNBUFFERED 1
ENV MLFLOW_HOME ./
ENV SERVER_PORT 5000
ENV MLFLOW_VERSION 0.7.0
ENV SERVER_HOST 0.0.0.0
ENV FILE_STORE ${MLFLOW_HOME}/fileStore
ENV ARTIFACT_STORE ${MLFLOW_HOME}/artifactStore
ENV PIP_DEFAULT_TIMEOUT 100
ENV PIP_DISABLE_PIP_VERSION_CHECK on
ENV PIP_NO_CACHE_DIR off
ENV POETRY_VERSION 1.0.0
WORKDIR ${MLFLOW_HOME}
FROM base as builder
RUN apk update \
&& apk add --no-cache make gcc musl-dev python3-dev libffi-dev openssl-dev subversion
#download project file from github repo
RUN svn export https://github.com/MChrys/QuickSign/trunk/ \
&& pip install poetry==${POETRY_VERSION} \
&& mkdir -p ${FILE_STORE} \
&& mkdir -p ${ARTIFACT_STORE}\
&& python -m venv /venv
COPY pyproject.toml ./
RUN poetry export -f requirements.txt | /venv/bin/pip install -r --allow-root-install /dev/stdin
COPY . .
RUN poetry build && /venv/bin/pip install dist/*.whl
FROM base as final
RUN apk add --no-cache libffi libpq
COPY --from=builder /venv /venv
COPY docker-entrypoint.sh ./
EXPOSE $SERVER_PORT
VOLUME ["${FILE_STORE}", "${ARTIFACT_STORE}"]
CMD ["./docker-entrypoint.sh"]
构建命令:
docker build - < Dockerfile
我收到这个错误:
Step 21/32 : COPY pyproject.toml ./
COPY failed: stat /var/lib/docker/tmp/docker-builder335195979/pyproject.toml: no such file or directory
pyproject.toml
requires = ["poetry>=1.0.0", "mlflow>=0.7.0", "python>=3.6"]
build-backend = "poetry.masonry.api"
[tool.poetry]
name = "Sign"
description = ""
version = "1.0.0"
readme = "README.md"
authors = [
""
]
license = "MIT"
[tool.poetry.dependencies]
python = "3.6"
numpy = "1.14.3"
scipy = "*"
pandas = "0.22.0"
scikit-learn = "0.19.1"
cloudpickle = "*"
mlflow ="0.7.0"
tensorflow = "^2.0.0"
[tool.poetry.dev-dependencies]
pylint = "*"
docker-compose = "^1.25.0"
docker-image-size-limit = "^0.2.0"
tomlkit = "^0.5.8"
docker-entrypoint.sh
#!/bin/sh
set -e
. /venv/bin/activate
mlflow server \
--file-store $FILE_STORE \
--default-artifact-root $ARTIFACT_STORE \
--host $SERVER_HOST \
--port $SERVER_PORT
如果我在第一个 COPY
之前添加 RUN pwd; ls
,我将获得:
Step 20/31 : RUN pwd; ls
---> Running in e8ec36dd6ca8
/
artifactStore
bin
dev
etc
fileStore
home
lib
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
trunk
usr
var
venv
Removing intermediate container e8ec36dd6ca8
---> d7bba641bd7c
Step 21/31 : COPY pyproject.toml ./
COPY failed: stat /var/lib/docker/tmp/docker-builder392824737/pyproject.toml: no such file or directory
试试看
docker build -t test .
而不是
docker build - < Dockerfile
我正在尝试构建一个 docker 容器,其中包含 mlflow 服务器,并使用 poetry toml 文件进行依赖。(这两个 toml 完全相同,这只是一种尝试弄清楚的方法)
树:
├── docker-entrypoint.sh
├── Dockerfile
├── 文件
│ └── pyproject.toml
├── git.sh
├── pyproject.toml
└── README.md
如你所见,我的 toml 文件在 Dockerfile 旁边 COPY pyproject.toml ./
不过还是不行
Dockerfile
FROM python:3.6.10-alpine3.10 as base
LABEL maintainer=""
ENV PYTHONFAULTHANDLER 1
ENV PYTHONHASHSEED random
ENV PYTHONUNBUFFERED 1
ENV MLFLOW_HOME ./
ENV SERVER_PORT 5000
ENV MLFLOW_VERSION 0.7.0
ENV SERVER_HOST 0.0.0.0
ENV FILE_STORE ${MLFLOW_HOME}/fileStore
ENV ARTIFACT_STORE ${MLFLOW_HOME}/artifactStore
ENV PIP_DEFAULT_TIMEOUT 100
ENV PIP_DISABLE_PIP_VERSION_CHECK on
ENV PIP_NO_CACHE_DIR off
ENV POETRY_VERSION 1.0.0
WORKDIR ${MLFLOW_HOME}
FROM base as builder
RUN apk update \
&& apk add --no-cache make gcc musl-dev python3-dev libffi-dev openssl-dev subversion
#download project file from github repo
RUN svn export https://github.com/MChrys/QuickSign/trunk/ \
&& pip install poetry==${POETRY_VERSION} \
&& mkdir -p ${FILE_STORE} \
&& mkdir -p ${ARTIFACT_STORE}\
&& python -m venv /venv
COPY pyproject.toml ./
RUN poetry export -f requirements.txt | /venv/bin/pip install -r --allow-root-install /dev/stdin
COPY . .
RUN poetry build && /venv/bin/pip install dist/*.whl
FROM base as final
RUN apk add --no-cache libffi libpq
COPY --from=builder /venv /venv
COPY docker-entrypoint.sh ./
EXPOSE $SERVER_PORT
VOLUME ["${FILE_STORE}", "${ARTIFACT_STORE}"]
CMD ["./docker-entrypoint.sh"]
构建命令:
docker build - < Dockerfile
我收到这个错误:
Step 21/32 : COPY pyproject.toml ./
COPY failed: stat /var/lib/docker/tmp/docker-builder335195979/pyproject.toml: no such file or directory
pyproject.toml
requires = ["poetry>=1.0.0", "mlflow>=0.7.0", "python>=3.6"]
build-backend = "poetry.masonry.api"
[tool.poetry]
name = "Sign"
description = ""
version = "1.0.0"
readme = "README.md"
authors = [
""
]
license = "MIT"
[tool.poetry.dependencies]
python = "3.6"
numpy = "1.14.3"
scipy = "*"
pandas = "0.22.0"
scikit-learn = "0.19.1"
cloudpickle = "*"
mlflow ="0.7.0"
tensorflow = "^2.0.0"
[tool.poetry.dev-dependencies]
pylint = "*"
docker-compose = "^1.25.0"
docker-image-size-limit = "^0.2.0"
tomlkit = "^0.5.8"
docker-entrypoint.sh
#!/bin/sh
set -e
. /venv/bin/activate
mlflow server \
--file-store $FILE_STORE \
--default-artifact-root $ARTIFACT_STORE \
--host $SERVER_HOST \
--port $SERVER_PORT
如果我在第一个 COPY
之前添加 RUN pwd; ls
,我将获得:
Step 20/31 : RUN pwd; ls
---> Running in e8ec36dd6ca8
/
artifactStore
bin
dev
etc
fileStore
home
lib
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
trunk
usr
var
venv
Removing intermediate container e8ec36dd6ca8
---> d7bba641bd7c
Step 21/31 : COPY pyproject.toml ./
COPY failed: stat /var/lib/docker/tmp/docker-builder392824737/pyproject.toml: no such file or directory
试试看
docker build -t test .
而不是
docker build - < Dockerfile