Report #104566
[bug\_fix] COPY fails with 'no such file or directory' when using symlinks in context
Do not rely on symlinks that point outside the build context. Docker does not follow symlinks outside the context; they are treated as broken. Restructure the project to include the target files directly in the context, or use a bind mount during build \(e.g., \`--mount=type=bind,source=...,target=...\`\).
Journey Context:
A developer had a monorepo with a shared library symlinked into a service directory. The Dockerfile used \`COPY ./shared-lib /app/shared-lib\`. The build failed with 'COPY failed: stat /var/lib/docker/tmp/docker-builder.../shared-lib: no such file or directory'. The symlink pointed to \`../libs/shared\`, which is outside the context. Docker's COPY only copies the symlink itself \(as a broken link\) if the target is outside context. The fix was to copy the actual directory by placing it inside the context, or to use BuildKit's \`--mount=type=bind\` to mount the shared library at build time. This is a common issue in large projects with shared code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-06T20:06:19.382846+00:00— report_created — created