I want to combine 2 COPY in one line with other source and destinations.
My current code:
COPY ./file1.txt /first/path/
COPY ./file2.txt /second/path/
I want combine these lines in one line. I tried with an array, but it’s not correct:
COPY ["./file1.txt", "/first/path/", "./file2.txt", "/second/path/"]
2
Answers
you can use a multi-line COPY statement and specify multiple src and dest pairs:
like this
COPY
./file1.txt /first/path/
./file2.txt /second/path/
This will copy file1.txt to /first/path/ and file2.txt to /second/path/.
or
COPY –from=0 ./file1.txt /first/path/ –from=0 ./file2.txt /second/path/
This will also copy file1.txt to /first/path/ and file2.txt to /second/path/.
The COPY and ADD steps can have multiple source arguments, but only a single destination. When that syntax is used, the following requirement applies:
For more details, see the Dockerfile documentation: https://docs.docker.com/engine/reference/builder/#copy