Container cannot write to a mounted directory: `Permission denied` / `EACCES`.
IntermediateTroubleshootingContainers that exit, crash or misbehave
Answer
Likely causes → UID mismatch between container user and host directory owner, read-only mount (:ro), SELinux label missing, or read-only root filesystem.
Diagnose →
docker exec c id
ls -ln /host/dir
docker inspect -f '{{json .Mounts}}' c
ls -Z /host/dir # SELinux
Fix → chown to the container UID, run with --user, add :z/:Z, drop :ro.
Prevent → Define fixed numeric UIDs.
More on Containers that exit, crash or misbehave
Container exits immediately with code 0 right after `docker run -d`.Beginner`Exited (137)` with no OOM flag.Intermediate`Exited (139)` segmentation fault.Advanced`Exited (126)` / `Exited (127)`.Beginner`exec /entrypoint.sh: exec format error`Intermediate`docker run` says `WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8)` and the app is very slow.Beginner