What are the instructions that create layers in Docker?
Experience Level: Senior
Tags: Docker
Answer
When you run an image and generate a container, you add a new writable layer (the “container layer”) on top of the underlying layers. All changes made to the running container, such as writing new files, modifying existing files, and deleting files, are written to this writable container layer.
Only the following instructions create layers during image build process:
- COPY
- RUN
- CMD
Other instructions create temporary intermediate images, and do not increase the size of the build.
Related Docker job interview questions
How can you ensure that some files will be ignored by a build process and won't be copied as part of COPY instruction that is defined in a Dockerfile?
Docker SeniorWhat Docker instruction will you use to copy files from one layer to another layer when you are creating a Dockerfile?
Docker SeniorWhat instructions do you use in Dockerfile to a previous stage as a new stage?
Docker SeniorWhat is the LABEL instruction good for in Docker?
Docker SeniorWhat is a difference between COPY and ADD instructions in Docker?
Docker Senior