# Add Failed File Not Found In Build Con 8df97a30cbc15a23

> Fixes 'ADD failed: file not found in build context or excluded by .dockerignore' during docker build. Use when ADD or COPY names a specific file the builder cannot see. Not for glob patterns matching nothing (the 'no source files' variant) or missing Dockerfiles.

- Skill: `vectle/add-failed-file-not-found-in-build-con-8df97a30cbc15a23` (Agent Skill)
- Install (CLI): `npx get-skill add vectle/add-failed-file-not-found-in-build-con-8df97a30cbc15a23`
- Raw SKILL.md: https://api.skillmd.com/api/skills/vectle/add-failed-file-not-found-in-build-con-8df97a30cbc15a23/raw
- Safety review: pending (external: skill-scanner PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- Author: Vectle (https://skillmd.com/u/vectle)
- Updated: 2026-11-19
- Page: https://skillmd.com/skills/vectle/add-failed-file-not-found-in-build-con-8df97a30cbc15a23

---


TL;DR: The named file is not in the build context, usually because .dockerignore excludes it. Open .dockerignore and add a `!` exception for the file (e.g. `!config/prod.json`), or move the file into the context. The error tells you the two possible causes right in the message; check .dockerignore first.

## The error

```text
ADD failed: config/prod.json: file not found in build context or excluded by .dockerignore: stat config/prod.json: file does not exist
```

## Fix it

1. Verify the file exists in the context root:
   `ls config/prod.json` (from the context dir)
   Expected: either missing (wrong path) or present (ignore rule).
2. Check .dockerignore:
   `grep -n "prod.json|config" .dockerignore`
   Expected: a matching exclude rule, often something broad like `config/` or `*.json`.
3. Add an exception (exceptions must come AFTER the excluding rule):
   `!config/prod.json`
4. Rebuild and confirm the ADD step passes.

## When this applies
- A specific file is named and the error mentions .dockerignore
- Secrets or env files that a broad ignore rule swallowed

## When this does NOT apply
- "COPY failed: no source files were found" (glob matched nothing at all)
- The file genuinely does not exist anywhere (create it or fix the path)

## Versions
All Docker versions, both builders.

## Why it happens
.dockerignore is applied when the client assembles the context, before any instruction runs. ADD then stats the file inside the context and fails. Broad rules like `*` followed by selective `!` re-includes are the usual culprit, and rule order matters: later lines override earlier ones.

## Edge cases
- `!` exceptions do not re-include files inside an excluded DIRECTORY unless you also re-include the directory path components.
- Whitespace and comments in .dockerignore follow gitignore-like rules; a trailing space in a pattern silently changes the match.
- COPY behaves identically here; the error text says ADD but the fix is the same.


---

Source: [Vectle](https://vectle.com/skills/skl_3ZSOqXqqJB040nznDUhmAw). Version: `skv_vq41oT0X3AOhq_j3DWU2kQ`. Original contributor attribution is preserved in the frontmatter. Content remains subject to [Vectle’s terms](https://vectle.com/terms) and its contributors’ rights; this mirror does not grant a new content license.

