.dockerignore Generator

Generate a .dockerignore that keeps your Docker builds fast, your images small and your secrets out of them. Pick your stacks — Node, Python, Go, Java, PHP, Rust, .NET or a front-end build — and get a file that always excludes .git, .env files and keys, with each rule explained. Add your own lines and download it. It's free, runs in your browser, and nothing is uploaded.

.gitignore vs .dockerignore

Pattern.gitignore.dockerignore
node_modulesAny depthTop level only
**/node_modulesAny depthAny depth
dir/DirectoryTrailing slash ignored
!keep.txtRe-includeRe-include

When to use it

  1. Speed up docker build by not sending node_modules and .git.
  2. Make sure .env files never get copied into an image.
  3. Add a .dockerignore to a project that only has a .gitignore.
  4. Combine rules for a monorepo with several languages.

How to Use

  1. Select the stacks in your project.
  2. Choose whether to include explanations.
  3. Add any project-specific rules.
  4. Download the .dockerignore into the folder you build from.

Features

  1. Always excludes .git, secrets and logs
  2. Nine stack presets
  3. Deduplicated rules
  4. Explanations per rule
  5. Custom rules
  6. 100% client-side

FAQs

Why do I need a .dockerignore?

Without one, the whole folder — including .git, node_modules and .env — is sent to Docker and can be copied into the image by COPY . .

Can I just copy my .gitignore?

Not directly. .dockerignore matches from the build-context root, so node_modules only matches the top level; use **/node_modules for nested folders.

Should the Dockerfile be ignored?

It's safe to — Docker still reads it — and it keeps it out of the image.

How do I keep one file that a pattern excludes?

Add a line starting with !, like !.env.example, after the rule that excludes it.

Is anything uploaded?

No. The file is generated in your browser.

Technical Details

Everything in the build context is sent to the Docker daemon before the build starts, and COPY . . will copy all of it into the image. A good .dockerignore therefore does three jobs: it keeps builds fast by not sending large folders such as .git or node_modules, keeps images small and reproducible by excluding locally built artifacts that the Dockerfile rebuilds anyway, and keeps secrets out — .env files, private keys and certificates would otherwise end up in an image layer that anyone with the image can read. A base set covering version control, secrets, logs, editor files, documentation and the Docker files themselves is always included, with an exception that keeps .env.example. Stack presets add each ecosystem's dependency folders, caches and build output, and rules shared between presets are written once. Patterns use .dockerignore's own matching, which is anchored at the context root, so nested folders are written with **/ — the most common mistake when copying a .gitignore. Each rule can carry a short comment explaining why it's there.

Developer Tools

Developer Tools

  • README Badge Generator
  • JSON to Zod
  • HTML Table Generator
  • Regex Cheatsheet
  • JSON to GraphQL
  • Regex Escape & Extract
  • AI Prompt Generator
  • Combine Files for AI