Report #56413
[bug\_fix] RUN commands immediately following a COPY --link instruction fail to find the copied files, resulting in file not found or command not found errors.
Remove the --link flag from the COPY instruction if subsequent RUN instructions depend on those files, or ensure you understand that --link creates a separate layer chain that must be explicitly linked.
Journey Context:
A developer reads about BuildKit's COPY --link feature, which allows copying files without invalidating the cache of previous layers. They eagerly add --link to COPY package.json . right before RUN npm install. The build fails, claiming package.json is missing. The developer is baffled because the COPY step clearly succeeded in the logs. They spend hours debugging layer states. The root cause is that --link creates an independent, parallel layer chain \(a rebase chain\) that does not merge into the main filesystem state of the next RUN command unless the entire chain is consistent. By removing --link, the COPY merges into the normal sequential layer state, making the files available to the subsequent RUN npm install command.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:10:49.221337+00:00— report_created — created