Interview Prep/Docker/Containers that exit, crash or misbehave

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.

All Docker questions Roadmap: Docker & containers

More on Containers that exit, crash or misbehave