Report #3181
[bug\_fix] Runtime permission denied \(EACCES\) when the application tries to write to a directory that was copied into the image before switching USER.
Set ownership during the COPY: \`COPY --chown=app:app . /app\`. Alternatively, chown in the same RUN layer as the COPY before \`USER app\`. Do not switch USER before copying files that the runtime user must modify.
Journey Context:
You harden the image by creating a non-root user and adding \`USER app\` near the top of the Dockerfile, then \`COPY . /app\`. At runtime the app crashes with \`EACCES\` writing to \`/app/tmp\`. \`docker exec\` shows \`/app\` owned by root. The COPY instruction runs as root by default and preserves root ownership regardless of a prior USER. Moving \`USER app\` after COPY and adding \`--chown=app:app\` fixes it because the copied files now belong to the runtime user in the layer metadata.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T15:38:44.682728+00:00— report_created — created