“ docker build”恰好需要1个参数 [英] "docker build" requires exactly 1 argument(s)

查看:282
本文介绍了“ docker build”恰好需要1个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从特定的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:


" docker build"恰好需要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 name of the Dockerfile (when it's different than regular Dockerfile). It is not for passing full path to docker build. Path goes as first argument.

语法是:

docker build [PARAMS]路径

因此,在您的情况下,这应该可行:

So in your case this should work:

docker build -f MyDockerfile -t proj:myapp / full / path / to /

或者如果您在项目目录中,您只需要使用一个点:

or in case you are in project directory, you just need to use a dot:

docker build -f MyDockerfile -t proj:myapp。

这篇关于“ docker build”恰好需要1个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆