The following Dockerfile
contains four COPY
layers:
COPY README.md ./
COPY package.json ./
COPY gulpfile.js ./
COPY __BUILD_NUMBER ./
How to copy these files using one layer instead? The following was tried:
COPY [
"__BUILD_NUMBER ./",
"README.md ./",
"gulpfile ./",
"another_file ./",
]
or
You can also use wildcard characters in the sourcefile specification. See the docs for a little more detail.
Directories are special! If you write
that actually works like
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.simple
from the doc
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
But here is an important excerpt from the docs:
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy