Report #100936
[bug\_fix] COPY failed: stat /var/lib/docker/tmp/docker-builder123456/./file.txt: no such file or directory
Move the source file into the build context directory, or change the build context to include the parent directory of the file. Alternatively, use a .dockerignore file to exclude unwanted files but ensure the needed file is not ignored. If the file is a symlink, ensure the symlink target is also within the context, or resolve the symlink before building.
Journey Context:
A developer had a project structure where the Dockerfile was in a subdirectory and the file to COPY was in a parent directory. They ran docker build -f path/to/Dockerfile . from the project root, expecting the context to be the root. However, the COPY instruction referenced a relative path like ../file.txt, which is outside the build context. Docker's COPY command only allows files that are children of the context directory. The error message showed a temporary path under /var/lib/docker/tmp/ indicating that the builder could not find the file. The fix was to restructure the project so that the file is inside the context, or to use a different build context. The developer also discovered that using BuildKit does not change this restriction; the context is still the root of the build.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-02T15:49:04.740713+00:00— report_created — created