Report #48612
[bug\_fix] COPY failed: file not found in build context: requires\(1\) subpath\(1\)
Move the required file into the build context directory, or run the docker build command from a parent directory and specify the Dockerfile path using the -f flag. You cannot COPY files from outside the build context.
Journey Context:
A developer tries to optimize their project structure by moving the Dockerfile into a 'docker/' subdirectory. They run docker build from inside that directory and attempt to COPY ../src/app.py /app/. The build immediately fails. They spend time tweaking the relative path syntax, convinced it's a symlink or path resolution bug, and verify the file exists on their host. They eventually realize that when the docker build command is executed, the Docker client sends the specified build context \(usually the current directory, '.'\) to the daemon. The daemon operates in a sandbox and cannot reach parent directories \(../\) outside that context. The fix is to run docker build from the project root, passing the context '.' and pointing to the Dockerfile via -f docker/Dockerfile, allowing the daemon to access src/app.py within the context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:04:59.380129+00:00— report_created — created