.dockerignore
A file listing paths to leave out of the build context, like .gitignore for Docker builds.
In more detail
Put .git, local virtual environments, build output and any .env or key files in it. This speeds up builds, keeps the build cache stable and stops secrets from being copied into an image by a broad COPY . . instruction.
Example
.git
.venv
__pycache__
.envRelated terms
- build context — The set of files you hand to docker build, usually the current directory given as the final dot.
- COPY — The Dockerfile instruction that copies files from the build context into the image.
- secret — Any value that grants access, such as a password, access token or private key, and must be kept out of code and version control.
Taught in
- Build Context, Dockerignore And Your First Dockerfile — Docker Architecture & Production Containers
- Minimal Bases, Non Root Users And Smaller Images — Docker Architecture & Production Containers
- Harden And Deliver The Complete Service Stack — Docker Architecture & Production Containers