docker - Why does Docker require PATH when building from custom Dockerfile in another directory?
问题描述
When building docker images with a Dockerfile
in the same directory, the following works every time
$ docker build -t project/app:latest .
Sending build context to Docker daemon 135.9MB
...
However, when using -f
to specify a different Dockerfile to use, docker complains ...
$ docker build -t project/app:latest -f ../some/path/Dockerfile.other
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
I can easily provide the PATH
, and the build will work, but why is the PATH
still required if I'm specifying the absolute path to the Dockerfile
with -f
?
解决方案
PATH
用于指定构建上下文(指令从中复制事物的树)COPY
,它不需要与 Dockerfile 的位置有任何关系。
该
docker build
命令从 Dockerfile 和“上下文”构建 Docker 映像。构建的上下文是位于指定PATH
或URL
. 构建过程可以引用上下文中的任何文件。例如,您的构建可以使用COPY
指令来引用上下文中的文件。
推荐阅读
- rasa - Rasa:创建自定义通道以通过 API 训练数据
- php - 为什么这个变量不是我们的上下文?
- python - django 当前路径,不匹配其中任何一个
- excel - 将日期和时间与excel中的日期时间列分开
- sed - Sed:从 txt 文件中删除行?
- selenium - 抓取 Lazada 数据
- python - 使用 scipy gaussian_kde 和 seaborn kdeplot 时的差异 KDE 渲染
- web-services - 在 WebSphere SOAP XOP 中,附件引用被替换为附件 base64 值
- java - 尝试运行“react-native run-android”时出错
- react-native - 如何设置某个区间的 ProgressBar - React Native(应该支持 IOS 和 Android)