Before explaining the use of the .dockerignore file, we need to spend a little time understanding what docker build .
Dockers. What happens when I create an image?
When you create an image from a Docker file using the docker build , the daemon creates a context. This context contains everything in the directory in which you executed the command.
What does dockerignore do and why use it?
The .dockerignore file allows .dockerignore to exclude files from the context, such as a .gitignore file, allows you to exclude a file from the git repository.
This helps make the assembly faster and easier by eliminating large files or a repository from the context that are not used in the assembly.
source share