我使用这个 docker build - < Dockerfile -t deepface
来构建一个 docker 镜像。
当我运行命令时它显示错误:
> ERROR [3/4] COPY ./requirements.txt /requirements.txt
> 0.0s
> ------
> > [3/4] COPY ./requirements.txt /requirements.txt:
> ------ failed to compute cache key: "/requirements.txt" not found: not found
我的导演文件是
>Deepface
|->Dockerfile
|->requirements.txt
我的requirements.txt是
numpy==1.19.5
pandas==1.2.4
gdown==3.13.0
tqdm==4.60.0
Pillow==8.2.0
opencv-python==4.5.2.52
tensorflow==2.5.0
keras==2.4.3
Flask==2.0.1
matplotlib==3.4.2
deepface==0.0.53
我的 Dockerfile 是
FROM python:3.9
WORKDIR /code
COPY ./requirements.txt /requirements.txt
RUN pip install -r ./requirements.txt
我该如何解决这个问题?
答案 0 :(得分:0)
这可能与this BuildKit docker issue有关。
为了查看这是否确实是问题所在,请尝试在禁用 BuildKit 的情况下进行构建:
$ DOCKER_BUILDKIT=0 docker build ...
如果这有帮助,那么您可以尝试其中之一来永久修复:
{ "features": { "buildkit": true } }
/etc/docker/daemon.json
c:\Users\CURRENT_USER\.docker\daemon.json
)。作为旁注,我建议避免将 requirements.txt
复制到容器的根文件夹。使用子目录,例如 /app
并在您的 WORKDIR
中使用 Dockerfile
使其成为基本目录。
作为辅助说明 - 而不是运行
docker build - < Dockerfile ...
你可以直接运行
docker build ...
答案 1 :(得分:0)
您使用的特定 docker build
语法
docker build - <Dockerfile
只有 Dockerfile; Docker build context 中没有任何其他内容,因此您无法将任何内容 COPY
放入映像中。即使这个语法是 in the docker build
documentation 我也不会使用它。
一个更典型的调用是将当前目录指定为构建上下文:
docker build -t deepface .
(不要忘记将您的应用程序代码也COPY
放入映像中,并设置容器应运行的标准CMD
。)