gotchaModeratependingCanonical
Docker volume permissions -- container runs as root but files owned by host user
Viewed 0 times
volume permissionsUIDrootchownuser mapping
dockerlinux
Error Messages
Problem
Files created by Docker container in mounted volumes are owned by root on the host. Or the container cannot write to mounted directories.
Solution
Match UIDs: In Dockerfile use RUN useradd -u 1000 appuser && USER appuser. Or docker-compose: user: '1000:1000'. macOS handles this automatically.
Why
Docker shares the host kernel. File permissions use numeric UIDs. Root in container (UID 0) creates root-owned files on host.
Revisions (0)
No revisions yet.