我尝试构建这个简单的 dockerfile,但它不起作用:
Dockerfil:
FROM nginx:latest
ADD . /usr/share/nginx/html
命令和输出:
ife@ife-HP-ProBook-6560b:~$ docker build -t web:latest .
[+] Building 1.1s (2/2) FINISHED
=> [internal] load build definition from Dockerfile 0.9s
=> => transferring dockerfile: 2B 0.3s
=> [internal] load .dockerignore 0.7s
=> => transferring context: 2B 0.2s
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount370739963/Dockerfile: no such file or directory
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount370739963/Dockerfile: no such file or directory
答案1
当找不到 Dockerfile 时,此错误很常见。
它的默认名称是Dockerfile
,并且区分大小写。dockerfile
例如,如果您的文件名为 ,请确保将D
文件名中的 大写。
否则,您可以传递--file
参数并覆盖默认名称。
docker build -t web:latest --file custom-dockerfile .