构建Dockerfile报错 "docker build" requires exactly 1 argument

背景

最近工作需要,用Dockerfile来构建镜像,找来的文档如下

https://yeasy.gitbooks.io/docker_practice/content/image/build.html

$ docker build -t nginx:v3 .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM nginx
 ---> e43d811ce2f4
Step 2 : RUN echo '<h1>Hello, Docker!</h1>' > /usr/share/nginx/html/index.html
 ---> Running in 9cdc27646c7b
 ---> 44aa4490ce2c
Removing intermediate container 9cdc27646c7b
Successfully built 44aa4490ce2c

照敲提示报错,

$ docker build -t centos_base:v1
"docker build" requires exactly 1 argument.
See 'docker build --help'.

Usage:  docker build [OPTIONS] PATH | URL | - [flags]

Build an image from a Dockerfile

感觉这其中必有蹊跷啊~

解决

按照问题处置标准流程?一字一字比对,发觉最后有一个点 . ??

后续

在官方文档找到了这样一段描述

https://docs.docker.com/engine/reference/commandline/build/ This example specifies that the PATH is ., and so all the files in the local directory get tard and sent to the Docker daemon. The PATH specifies where to find the files for the “context” of the build on the Docker daemon. Remember that the daemon could be running on a remote machine and that no parsing of the Dockerfile happens at the client side (where you’re running docker build). That means that all the files at PATH get sent, not just the ones listed to ADD in the Dockerfile.

# USAGE
docker build [OPTIONS] PATH | URL | -
# e.g.
docker build .

意思是说,在官方文档的示例里,PATH指明了.,然后在当前目录下的多有文件都被发送进了Docker的守护进程,PATH指定了构建镜像时上下文查找文件的路径。比如Dockerfile 里ADD指令的第一个参数可以从上下文也就是刚刚发送进Docker Daemon的文件中找到。

?写这篇为了说明啥,说明执行结果不在预期时,要更加关注平时会忽略的地方~

转载于:https://my.oschina.net/mythss/blog/3009856

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值