Issue when trying to write to a mounted volume from inside a container as a non-root user Issue when trying to write to a mounted volume from inside a container as a non-root user docker docker

Issue when trying to write to a mounted volume from inside a container as a non-root user


To my knowledge, user ID and group ID inside the container and on the host machine should match, in order to let the host machine to grant you permissions to the share directory.


Very important to see the difference between running a production and a development container.Afaik, there's no real issue if your Docker container runs as root, even on production. However you should never want or need to mount a volume of production. If you want to run it as a zookeeper feel free to do so.

// Edit: The more I read, the more I'm convinced there actually might be a security issue when running stuff as root, so you better not doing so on production.

The solution to try and match uid and gid is viable only for small/local project - it really does make it unportable. You can try and set an arbitrary high uid and gid and then do the same on each of your devs machines, but that doesn't mean it'll always be fine.

tl;dr: On development run chmod -R 0777 on existing files and then umask 0000 to setup permissions on files and directories created later. Then you can mount and edit your files as you please, no matter what user created it.