Optimized Dockerfile

Hello,

I have a question to optimize my Dockerfile and build .

In the Dockerfile I have several COPY lines and I would like to reduce the number of layers to only be able to have one COPY line.

COPY folder1 /user/folder1
COPY folder2 /user/folder2
COPY otherfolder /user/otherfolder
COPY libfolder /user/tp/libfolder

I tried several things but it doesn’t work!

COPY [
           "folder1 /user/folder1",
           "folder2 /user/folder2",
           "otherfolder /user/otherfolder",
           "libfolder /user/tp/libfolder",
]

Do you know a way to do this?

Thank’s

Organize your source file into one folder with subfolders and files and copy that one root folder. For example:

COPY user /user

The result will be merged with the existing content inside the image.

Thanks a lot for the idea. I will test.