.DOCKERIGNORE EXPLAINER · RUNS IN YOUR BROWSER · NOTHING UPLOADED

What does docker build send, and why does COPY say “not found”?

Give it your .dockerignore, your file list and, if you like, your Dockerfile. For every path you get whether BuildKit sends it and the line that decides. It also flags COPY sources your rules exclude, .env files, keys and .git still sent, patterns that only match at the root (*.log is not **/*.log here), and !folder lines that re-include nothing. Then it writes a fix and re-checks it against your files.

The engine is a line-by-line port of the code BuildKit runs (moby/patternmatcher and tonistiigi/fsutil). It agrees with that code on 5,000 random trees replayed in every test run, and on 25,000 more run once; the README says how. Your own docker build is still the final word.

1. Your build context

Reads only names and sizes, plus the .dockerignore and Dockerfile at the top, if there are any. Nothing is uploaded. Or paste the lists below.

From find . -type f or git ls-files. For sizes, use find . -type f -printf '%s %p\n'. End a line with / for an empty folder.

Why is one path left out?

The steps BuildKit takes, folder by folder, with the .dockerignore above.

    How BuildKit reads a .dockerignore

    Guide with worked examples: why a .dockerignore pattern does not match in subfolders.

    From a terminal

    The same engine runs over a real context folder, with no install and no network. It reads the folder, .dockerignore (or <Dockerfile>.dockerignore, as BuildKit does) and the Dockerfile.

    node ventures/dockerignore-explainer/cli/check.mjs .                 # report
    node ventures/dockerignore-explainer/cli/check.mjs . --why src/a.js  # the steps for one path
    node ventures/dockerignore-explainer/cli/check.mjs . --fixed         # print the checked fix
    node ventures/dockerignore-explainer/cli/check.mjs . --strict        # exit 1 on a high finding (CI)

    Clone the source, then pass your context folder. Node 18 or later.

    Questions

    Why does *.log in .dockerignore not exclude logs in subfolders?

    Because .dockerignore patterns are matched from the root of the build context, not at any depth like .gitignore. *.log matches app.log but not logs/app.log. Write **/*.log to match at every depth, and **/node_modules for node_modules folders inside packages.

    Why does COPY fail with not found when the file exists?

    Usually because a .dockerignore line excludes it. BuildKit sends only the files your rules let through, and COPY can only read what was sent, so an excluded source fails with a not-found error. Paste your Dockerfile with the .dockerignore and file list and the tool names the line that excludes each COPY source.

    Why does !docs not re-include the files in docs?

    BuildKit carries an exception for a folder down to the folder's contents only when the folder itself was excluded first. With **/*.md followed by !docs, the folder docs was never excluded, the Markdown files inside were matched directly, and !docs never reaches them. Write !docs/** instead.

    Is [!a] a negated character class in .dockerignore?

    No. Docker uses Go's pattern rules, where a class is negated with ^, as in [^a]. [!a] matches the character ! or a. And because the pattern becomes a regular expression, a negated class like [^a] can also match a slash.

    Can I put a comment in .dockerignore?

    Only on its own line, starting in the first column. A # after a pattern becomes part of the pattern, and a # line with spaces in front of it is trimmed and read as a pattern, not a comment.

    Does excluding the Dockerfile or .dockerignore break the build?

    Not with BuildKit, the default builder since Docker Engine 23. The Dockerfile is read separately from the context, so excluding it only keeps it out of what COPY . . copies into the image.

    Is anything I paste or pick uploaded?

    No. The checker runs entirely in this browser tab. Picking a folder reads only file names, sizes and the .dockerignore and Dockerfile at its top; no file content leaves your device, and the command-line version makes no network calls.