Report #6397
[bug\_fix] Changes made in a RUN --mount=type=bind instruction do not persist in the container's filesystem
Use RUN --mount=type=cache for persistent cache directories, or COPY for build artifacts. type=bind is for read-only mounting of build contexts or previous stages and does not write back to the filesystem layer.
Journey Context:
A developer tries to use 'RUN --mount=type=bind,target=/app/node\_modules npm install' expecting the installed node\_modules to persist in the image. The build succeeds, but at runtime, node\_modules is missing. They read the BuildKit documentation and realize type=bind mounts a directory from the context or another stage, effectively shadowing the target path, and writes inside the mount are discarded. They switch to 'COPY package.json . && RUN npm install' or 'RUN --mount=type=cache,target=/root/.npm npm install' to properly cache the downloads while persisting the installation in the layer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:53:39.757054+00:00— report_created — created