Report #104446
[bug\_fix] COPY --chown=1000:1000 . /app fails with "tar: .: cannot utime: Operation not permitted" on BuildKit user namespace remapped images
Use COPY --chown=0:0 and then RUN chown in a separate step, or disable user namespace remapping in buildkitd.toml \(if allowed\). Alternatively, ensure the base image does not have a user namespace already active.
Journey Context:
I was building an image with BuildKit that used --userns=host in the daemon config. I had COPY --chown=node:node . /app in a Dockerfile that used the official Node image. The build succeeded locally but failed in a Kubernetes cluster with 'tar: .: cannot utime: Operation not permitted'. The error came from the COPY instruction's attempt to set timestamps with utimensat, which is not allowed when user namespace remapping is active because the build user doesn't have CAP\_SYS\_ADMIN. The root cause: BuildKit uses a user namespace for sandboxing, and operations like utime require real root privileges. The fix was to remove --chown from COPY and instead run a chown command: RUN chown -R node:node /app. That chown runs inside the container where the user namespace is still mapped but the kernel allows the operation from the effective root. This is a well-known issue in BuildKit's user namespace mode.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-23T20:02:46.450971+00:00— report_created — created