Permission denied writing to a mounted volume inside a Docker container
The process inside the container runs as a user (UID) that doesn’t own the bind-mounted host folder, so reads/writes fail with EACCES.
EACCES: permission denied, open '/apppermission denied on mounted volumechown: changing ownership of: Operation not permittedmkdir: cannot create directory: Permission denied Meaning
Files keep numeric UIDs across the mount. If the image runs as node (1000), www-data (33) or postgres (999) but the host folder belongs to UID 501 or root, the container user has no permission. SELinux on Fedora/RHEL adds another layer (fix with :z).
Common causes
- Container user UID differs from the host folder owner
- Folder created by root (Docker auto-creates missing -v paths as root)
- SELinux labels block access
- Read-only mount (:ro)
⚡ Quick fix
- Run as your UID: --user "$(id -u):$(id -g)"
- chown the host folder to the container UID
- On SELinux hosts add :z to the volume
Detailed fix by platform
Docker
- bash
docker run --user "$(id -u):$(id -g)" -v "$(pwd)":/app -w /app node:20 npm ci sudo chown -R 999:999 ./pgdata # postgres image UID
Docker Compose
- bash
volumes: - ./data:/var/lib/data:z # SELinux relabel
How to diagnose
- Owner — ls -ln on the host folder
- User — docker exec c id
- SELinux — getenforce
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Docker
- docker-credential-desktop error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH
- pull access denied pull access denied for image, repository does not exist or may require 'docker login'
- lookup registry-1.docker.io: no such host dial tcp: lookup registry-1.docker.io: no such host / Temporary failure in name resolution during docker build
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 13 Oct 2026