Should I Change Ownership of Docker Mounted Directories?

0
0
Asked By CoolCat77 On

Hey everyone! I'm currently running Docker on my Ubuntu machine using several docker-compose files, and I have my directory mounts located at /opt/appdata. Each of my containers has its own subdirectory in there. Right now, some of these directories are owned by root and others by my user with ID 1000. Is it considered best practice to change all of them to be owned by 1000? Any thoughts? Thanks!

1 Answer

Answered By DockerDude23 On

The ownership and permissions should match what the application inside the container needs. Just keep in mind that user IDs can differ between the host and the container. For production environments, it's better to run applications in containers as non-privileged users, ideally a user that doesn’t exist on the host to avoid ID collisions. However, for development, it might be easier to run the container with the same user ID you use on your host, like 1000, so you won’t face file access issues.

CoolCat77 -

Thanks for your insights! This is more for home use than production, so changing ownership to 1000 on /opt/appdata sounds like the way to go.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.