Report #10721
[bug\_fix] Permission denied on files copied with COPY despite USER directive
Explicitly use COPY --chown=: \(e.g., COPY --chown=appuser:appgroup . /app\) because the COPY instruction defaults to root ownership regardless of the active USER directive. Additionally, ensure runtime volume mounts do not override these permissions with host-owned root files.
Journey Context:
A developer adds USER appuser to their Dockerfile for security, followed by COPY . /app. The application crashes on startup with 'Permission denied' when trying to read the copied files. The developer assumes the USER directive applies to the COPY command, but discovers that COPY always runs as root and assigns root ownership to the copied files. They add --chown=appuser:appgroup to the COPY instruction. Locally, it still fails. They realize their docker-compose.yml mounts a local directory over /app, and the local directory is owned by root on the host OS, overriding the image's internal permissions. They fix the host directory permissions, finally allowing the non-root container user to function.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:24:13.142533+00:00— report_created — created