Dockerignore Generator
Generate clean, production-shaped .dockerignore files with stack presets to shrink build contexts and protect secrets.
Written after the stack sections, so an exception here can override a rule above it. Lines starting with # are kept as comments.
What you type stays in this box: it is never written to storage, and it travels only inside a link you choose to copy.
Tick a stack on the left and the merged file appears here, with every line explained underneath it.
The file is assembled inside this page. Open the Network panel, tick a stack, and nothing appears in it.
Press ? for shortcuts
Do it offline:$
How to use it
- Select the technology stacks utilized in your repository (such as Node.js/TypeScript, Python, Go, or Rust).
- Toggle whether to include foundational rules for version control, temporary files, local environment overrides, and operating system caches.
- Add any custom repository paths or files to ignore in the custom rules text box.
- Copy the generated file directly or download it as .dockerignore and place it into your project root next to your Dockerfile.
Generate optimized, production-grade .dockerignore files tailored for Node.js, Python, Go, Rust, and Java projects. Dramatically speed up container build times, reduce image size, and prevent secret leaks.
How it works
When you run 'docker build', Docker sends the entire build context directory to the Docker daemon. Unignored directories like node_modules, target, or .git cause massive slow-downs.
A .dockerignore file functions similarly to .gitignore: patterns tell Docker CLI to filter out files and directories before sending the context tarball over the pipe.
This generator combines proven community best practices for each selected stack, automatically resolving and deduplicating overlapping wildcard patterns.
The tool executes entirely in your browser using pure TypeScript logic with zero external server dependencies.
Examples
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
Common errors
FAQ
Why should node_modules or venv be in .dockerignore if my Dockerfile needs them?
Your container image should build dependencies natively inside Linux using 'RUN npm ci' or 'pip install'. Copying host machine binaries causes runtime architecture incompatibilities and balloons context size.
Does .dockerignore prevent sensitive .env files from being leaked?
Yes. If a .env file is in the build context and your Dockerfile uses 'COPY . .', secrets become baked into the container image layers forever. Excluding .env via .dockerignore protects against accidental inclusion.
What is the difference between .gitignore and .dockerignore?
.gitignore controls what Git tracks, while .dockerignore controls what Docker sends to the build engine. Often build output (dist/target) is ignored in git but needed during container build steps.