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?
Experience Level: Senior
Tags: Docker
Answer
To exclude files not relevant to the build (without restructuring your source repository) use a .dockerignore file. This file supports exclusion patterns similar to .gitignore files. For information on creating one, see the .dockerignore file.
Related Docker job interview questions
What are the instructions that create layers in Docker?
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