“码头工人构建"恰好需要 1 个参数 [英] "docker build" requires exactly 1 argument(s)
问题描述
我正在尝试从特定的 Dockerfile 构建映像,并同时对其进行标记;我正在关注 在线说明docker build
,但我收到以下错误:
I am trying to build an image from a specific Dockerfile, and tag it at the same time; I am following the online instructions fordocker build
, but I get the following error:
码头工人构建"只需要 1 个参数
"docker build" requires exactly 1 argument(s)
我的目录结构:
project/
foo/
MyDockerfile
这是我运行的命令:
docker build -f/full/path/to/MyDockerfile -t proj:myapp
我尝试了上述命令的各种组合,但结果始终是上面给出的错误消息.为什么会发生这种情况 - 正如我按照文档所说的那样?
I have tried various combinations of the above command, but the results are always the error message given above. Why is this happening - as I am following what the documentation says?
推荐答案
参数 -f
更改 Dockerfile 的名称(当它不同于常规的 Dockerfile
时).它不适用于将完整路径传递给 docker build
.路径作为第一个参数.
Parameter -f
changes the name of the Dockerfile (when it's different than regular Dockerfile
). It is not for passing the full path to docker build
. The path goes as the first argument.
语法是:
docker build [PARAMS] PATH
所以在你的情况下,这应该有效:
So in your case, this should work:
docker build -f MyDockerfile -t proj:myapp/full/path/to/
或者如果你在项目目录中,你只需要使用一个点:
or in case you are in the project directory, you just need to use a dot:
docker build -f MyDockerfile -t proj:myapp .
这篇关于“码头工人构建"恰好需要 1 个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!