Create a Docker ignore file for Node.js, Python, Java, Go, Rust, PHP, and .NET projects.
Last updated: March 2026 | By Workshelve Team
Choose a stack to add language-specific exclusions.
Supports comments, wildcards, directory patterns, character classes like *.py[cod], and negation with !.
The tester approximates Docker .dockerignore behavior including directory matches, Go-style wildcards such as [cod], **, and order-sensitive ! negation.
A .dockerignore file tells Docker which files and folders to leave out of the build context. It works like .gitignore, but for Docker builds instead of Git.
When you run docker build, Docker sends files from your project into the build context. Excluding dependency folders, logs, local secrets, editor files, and generated output can make builds faster and reduce accidental leaks.
A good Docker ignore file is especially useful for Node.js, Python, Java, Go, Rust, PHP, and .NET projects where local dependency folders or cache directories can be large.
Choose a project type, review the common exclusions, then copy or download the generated file as .dockerignore.
.dockerignore beside your Dockerfile.docker build.A typical Node.js Docker ignore file:
# Secrets and credentials .env .env.* !.env.example *.key *.pem # Node.js node_modules/ .npm/ .yarn/ dist/ build/ .next/ .turbo/ coverage/ # Version control .git/ .gitignore # Logs *.log logs/ npm-debug.log* yarn-debug.log* # OS files .DS_Store Thumbs.db
Use the pattern tester to check whether a path would be excluded. Directory patterns like node_modules/ should match nested files such as node_modules/react/index.js.
Pattern order matters. A later negation pattern starting with ! can re-include a file that was previously excluded, such as !.env.example.
Put .dockerignore in the build context root, usually the same folder where you run docker build. It is commonly placed beside the Dockerfile.
It can, but its main job is reducing the build context. Image size only changes if excluded files would otherwise be copied into the image.
Usually yes for Node.js images. The Dockerfile should install dependencies inside the image so the result matches the container environment.
Only if your build does not need them. Some projects use tests, docs, or metadata during build, so this generator keeps those optional.
Yes. Use ! to re-include a file after a broader exclusion. A common example is excluding .env.* but keeping !.env.example.
Yes. Compose uses .dockerignore when it builds an image from a local build context.