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

后端 未结 4 919
灰色年华
灰色年华 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:38

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

    or

    COPY ["__BUILD_NUMBER", "README.md", "gulpfile", "another_file", "./"]
    

    You can also use wildcard characters in the sourcefile specification. See the docs for a little more detail.

    Directories are special! If you write

    COPY dir1 dir2 ./
    

    that actually works like

    COPY dir1/* dir2/* ./
    

    If you want to copy multiple directories (not their contents) under a destination directory in a single command, you'll need to set up the build context so that your source directories are under a common parent and then COPY that parent.

提交回复
热议问题