Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in DevOps and Agile by (2.3k points)

My Dockerfile has four COPY layers:

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

How can I copy all of these files by using just one layer instead?

I also tried this:

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

1 Answer

0 votes
by (6.9k points)
edited by

Try this command out:
COPY README.md package.json gulpfile.js __BUILD_NUMBER ./

or

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

You can also make use of the wild card characters in your sourcefile.

Keep in mind that directories are a bit special, so when you write:

COPY dir1 dir2 ./

it actually works like this

COPY dir1/* dir2/* ./

try out docker training course, and learn with first hand experience from people who have had years of knowledge in docker

Browse Categories

...