What is the default location for included files when building a docker image?

南楼画角 提交于 2019-12-29 01:26:07

问题


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

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?


回答1:


Those files are not part of the built (end-result) image.

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.

A build’s context is the files located in the specified PATH or URL

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

This is managed by Context and ModifiableContext.



来源:https://stackoverflow.com/questions/34325540/what-is-the-default-location-for-included-files-when-building-a-docker-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!