Docker "failed to compute cache key: failed to walk" (Broken Symlink) in CI
BuildKit could not walk the build context to compute a COPY cache key. failed to walk <path> means a path in the context - usually a broken/dangling symlink or an unreadable entry - could not be traversed.
What this error means
A COPY step fails with failed to compute cache key: failed to walk /<path>: lstat ...: no such file or directory, pointing at a symlink whose target is missing or outside the context.
ERROR: failed to solve: failed to compute cache key: failed to walk /var/lib/buildkit/.../node_modules/.bin/foo:
lstat /var/lib/buildkit/.../node_modules/.bin/foo: no such file or directory
# .bin/foo is a symlink whose target is missingCommon causes
A dangling symlink in the context
A symlink whose target was removed (or points outside the context) cannot be resolved while walking, so the cache-key computation fails.
A symlink that escapes the context
A symlink pointing to an absolute path outside the build context cannot be traversed by BuildKit and breaks the walk.
An unreadable entry in a copied directory
A path the builder cannot stat (permissions, special file) during the walk fails the cache-key step.
How to fix it
Exclude or fix the broken symlink
Keep the dangling symlink out of the context or repair its target.
# .dockerignore - keep generated/linked trees out of the context
node_modules
**/.binCopy only the directories you need
Narrow the COPY so the walk never touches the broken link.
# copy sources, then install in-image (no host symlinks copied)
COPY package*.json ./
RUN npm ci
COPY src/ ./src/How to prevent it
- Exclude generated/symlinked directories (e.g.
node_modules) via.dockerignore. - Install dependencies in-image rather than copying host symlink trees.
- Avoid symlinks in the context that point outside it.