Linux users and groups might seem a bit difficult to set up properly at the beginning on Docker and the host system.

This guide will show some best practices how to deal with users, groups and permissions when mounting volumes and adding folders from the host to Docker images.

What is the main issue?

User from a host is a different one compared to a user within a Docker container. These two users have also different id.

You can get a user id by running the id command:

See that which process runs as which user:

ps aux

Check the id of specific user, for example, user www-data:

id www-data # will be "33" in Ubuntu containers/servers



usermod command modifies a user account.


chown -R 33 application/



See also

Recommended read and video tutorials:

Found a typo? Something wrong with this content?

Just fork and edit it.

Content of this work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. Code snippets in examples are published under the CC0 1.0 Universal (CC0 1.0). Thanks to all contributors.