How to copy multiple files in one layer using a Dockerfile?

后端 未结 4 909
灰色年华
灰色年华 2020-12-02 08:47

The following Dockerfile contains four COPY layers:

COPY README.md ./
COPY package.json ./
COPY gulpfile.js ./
COPY __BUILD_NUMBER          


        
4条回答
  •  遥遥无期
    2020-12-02 09:30

    It might be worth mentioning that you can also create a .dockerignore file, to exclude the files that you don't want to copy:

    https://docs.docker.com/engine/reference/builder/#dockerignore-file

    Before the docker CLI sends the context to the docker daemon, it looks for a file named .dockerignore in the root directory of the context. If this file exists, the CLI modifies the context to exclude files and directories that match patterns in it. This helps to avoid unnecessarily sending large or sensitive files and directories to the daemon and potentially adding them to images using ADD or COPY.

提交回复
热议问题