Docker · infra · fg-0266

Non-root container gets 'Permission denied' writing to a mounted volume

If you see EACCES: permission denied, open '/data/app.db', the cause and the fix for Docker are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
EACCES: permission denied, open '/data/app.db'mkdir: cannot create directory '/app/uploads': Permission denied
Cause
A new named volume takes the owner of the directory at that path in the image, so a path missing from the image, or left owned by root, gives a root-owned volume. Bind mounts keep the host's numeric owner and Docker does not remap it.
Fix
Create and chown the mount path in the Dockerfile before switching USER, then remove the old volume so it is recreated with the new owner. For bind mounts, run the container with the UID that owns the host directory.
Apply
RUN mkdir -p /data && chown -R node:node /data USER node # existing volume keeps old ownership: docker volume rm <name> and start again
Affected
Docker Engine local volume driver and bind mounts, as of October 2026
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun