The .dockerignore file
If you are familiar with using .gitignore files, then you will already have a basic understanding of the purpose for the .dockerignore file. The .dockerignore file is used to exclude files that you do not want to be included with the build context during a docker image build. Using it helps to prevent sensitive and other unwanted files from being included in the build context, and potentially in the docker image. It is an excellent tool to help keep your Docker images small.
The .dockerignore file needs to be in the root folder of the build context. Like a .gitignore file, it uses a newline-separated list of patterns. Comments in the .dockerignore file are denoted by a # as the first character of a line. You can override ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access