Skip to content
gohacks.dev
DevOps

.dockerignore Generator

Generate a .dockerignore that keeps .git, .env files, keys, node_modules, vendor and build output out of the Docker build context.

Free · No sign-up · Your inputs stay in your browser

Input

Generate a .dockerignore

Output

.dockerignore

318 characters

Everything not ignored is sent to the builder as the build context, so a missing node_modules line can upload hundreds of megabytes before the first step runs, and a missing .env line bakes secrets into an image layer anyone who pulls it can read. Patterns follow Go's filepath.Match, plus ** and ! exceptions.

Runs in this browser. Nothing you paste is sent to a server.

Why it matters

Everything not ignored is sent to the builder as the build context before the first instruction runs, so a forgotten node_modules can add hundreds of megabytes and minutes to every build. Worse, COPY . . copies whatever was sent: a .env file in the context ends up in an image layer that anyone who can pull the image can read, even if a later step deletes it.

Pattern syntax

Patterns follow Go's filepath.Match with ** for any number of directories and ! for exceptions, applied in order, as described in the .dockerignore documentation. It is not the same as .gitignore: a bare name matches only at the root unless prefixed with **/.

Share

Frequently asked questions

Is a file deleted in a later Dockerfile step really gone?
No. Each instruction adds a layer, and earlier layers remain in the image. Keep secrets out of the context, or use build secrets (RUN --mount=type=secret).
Should .dockerignore exclude the Dockerfile itself?
It can. The Dockerfile is still read by the builder; excluding it only stops COPY . . from putting it in the image.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools