What Docker instruction will you use to copy files from one layer to another layer when you are creating a Dockerfile?

Experience Level: Senior
Tags: Docker

Answer

Option 1: Copy a file from previous stage to a new stage:
FROM image AS stage1
# ...

FROM image AS stage2
COPY --from=stage1 /files /new-target-folder

Option 2: Copy a file from an external image as a "stage":
COPY --from=nginx:latest /etc/nginx/nginx.conf /nginx.conf



Comments

No Comments Yet.
Be the first to tell us what you think.
Docker instructions
Docker instructions

Are you learning Docker ? Try our test we designed to help you progress faster.

Test yourself