构建 docker 镜像时包含文件的默认位置是什么? [英] What is the default location for included files when building a docker image?
问题描述
derrend@laptop ~/topdir $ docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64
<小时>
derrend@laptop ~/topdir $ pwd; ls *
$HOME/topdir
Dockerfile
afolder:
afile
据我所知,当我执行 docker build
时,afolder
及其内容将包含在我的 docker 映像中,但如果我不这样做,它们将被放置在哪里在 Dockerfile
?
As I understand it, when I execute a docker build
the afolder
and its contents will be included inside my docker image but where will they be placed if I do not designate a location in the Dockerfile
?
推荐答案
那些文件不是构建(最终结果)图像的一部分.
Those files are not part of the built (end-result) image.
它们是传递给守护进程的构建上下文的一部分在构建过程中,由 Dockerfile 指令使用,例如 <代码>添加或COPY
或 RUN
.
They are part of the build context passed to the daemon during the build process, to be used by Dockerfile directives like ADD
or COPY
or RUN
.
构建的上下文是位于指定 PATH 或 URL
A build’s context is the files located in the specified PATH or URL
例如,运行此命令以使用分支容器中名为 docker 的目录:
For example, run this command to use a directory called docker in the branch container:
$ docker build https://github.com/docker/rootfs.git#container:docker
这由Context<管理/code> 和
.ModifiableContext
这篇关于构建 docker 镜像时包含文件的默认位置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!