I am trying to use the du
command as one user from inside a docker container (Telegraf) to get the disk usage of various directories on an external drive. My set up looks like this:
Both the docker containers run their services as the same user (monitor_usr:monitor_usr
, UID/GID 1001:1001
). The problem is essentially that all various files and directories on the external drive are created/managed by a variety of different users, and are therefore owned by different users. However, the du
command requires executable permissions in order to get the correct disk size. The user monitor_usr
doesn’t own or have executable permissions on all the files created in the external drive by other users.
My thoughts:
- I don’t want to just chmod all files on the drive to allow all users access. I also don’t think this approach would work anyway, because as new files are created on the external drive they would also need chmod after each creation.
- I thought about creating a group (e.g.
drive_usrgrp
), with the intention of having all users that need to use the drive have full permissions. However, I think the issue would remain when new users (in other containers/VMs) create new files – they would again need to be chmod. Also, when I start the docker container currently with usermonitor_usr:monitor_usr
I would then have to start it something likemonitor_usr:drive_usrgrp
.
What’s a good way to set these permissions up properly?