J. JieraltField Notes
Technical guide

Permission errors on a Docker bind mount: compare UID and GID

Check Linux file ownership, the container process identity and read-only mounts without masking the cause with chmod 777.

Why the host can write but the container cannot

Linux normally checks numeric UID and GID values. A username shown on the host may not represent the same identity in the container. If the process runs as a different UID, it may not be allowed to write to a bind-mounted directory.

Compare both identities and the mount

id
stat -c '%u:%g %a %n' ./data
docker compose exec app id
docker inspect app --format ''

Replace app with the actual container name. Compare the host directory owner, container process UID/GID, and Compose settings for read_only, mount target and runtime user. docker inspect may reveal internal paths; review its output before sharing.

Make the smallest permission change

Once you know which identity needs access, adjust only the target directory's owner or group permissions, or run the service with the intended UID/GID. Test reads, writes and upgrades outside production first. If the service only needs to read configuration, a read-only mount may be the better choice.

Do not use chmod -R 777 as a generic fix: it grants every local user write access and can overwrite intentional per-file permissions. User namespaces, rootless Docker and NFS add UID mapping behavior that must be checked for the specific environment.

References

Still not working after these steps?

Send me the error and your environment for a free first diagnosis. Hands-on help is quoted before any work starts.

Get a free checkor ask the forum
Want new fixes as they land?Subscribe via RSS →