I have dockerized an application which accesses a folder "Folder1" inside the container. The folder is owned by a user "user1". When I bring the container up, I need to mount this folder over my host machine. Upon doing so, the ownership of "Folder1" inside the container changes to root as the corresponding mapped folder is under root's ownership on the host machine.

This change of ownership makes the folder inaccessible to my application inside the container. Any idea how do I fix this?

  • Is it ok to change the ownership of the folder on the host, or do you want your container to run as a user and access a host folder that's owned by root, without changing either?
    – BMitch
    Oct 6, 2018 at 12:31
  • @BMitch : I just observed a weird thing. If I map the mounted folder to a folder that is not owned root but by any other user on the host machiner, then the folder inside the container retains the ownership. I wonder what's so special about root.
    – 7_R3X
    Oct 6, 2018 at 13:02

1 Answer 1


At least in the *nix world the ownership (i.e. uid and gid) of a file/folder on a mounted filesystem doesn't change, it is the actual ownership from the host exporting that filesystem (if ownership is supported by that filesystem).

Note that if the container has different user/group names matching the uid/gid of the file/folder they will appear under the container's names in ls -l, not as the host's names (or as numbers if no container names match the respective IDs).

So if on the host machine the folder is owned by root, it will also be owned by root in the container (in other words it's nothing "special" about it being owned by root vs other users). The only way to allow the container app to write to the filesystem is to change the ownership accordingly on the host system (or give it other write permissions).

Maybe worth noting that if the host's filesystem itself doesn't support ownership, it can still be "faked" inside the container using the uid and gid mount options (in the *nix world). See Ownership of a mount point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.