Report #64696
[bug\_fix] Build context is huge and slow, or COPY fails with file not found despite the file existing in the repository
Ensure \`.dockerignore\` is located in the root of the build context \(the directory passed to \`docker build\`\), not just next to the Dockerfile if it is in a subdirectory, and use correct glob patterns to exclude unnecessary files like \`.git\`.
Journey Context:
A developer runs \`docker build -t myapp -f docker/Dockerfile .\` from the repo root. They notice the build context is 2GB because it includes the \`.git\` history and \`node\_modules\`. They add a \`.dockerignore\` file inside the \`docker/\` directory next to the Dockerfile. Nothing changes. They try modifying \`.gitignore\`, but Docker still sends the \`.git\` folder. The rabbit hole is realizing that the \`.dockerignore\` file \*must\* be at the root of the build context directory \(the \`.\` in \`docker build .\`\), not next to the Dockerfile. Moving \`.dockerignore\` to the repo root fixes the context size. This works because the Docker CLI specifically looks for a \`.dockerignore\` file in the context root directory before tarballing it to send to the daemon.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T15:04:47.758369+00:00— report_created — created