I need to run a docker-compose up -d --build command to run a project. Some containers will write files to the volume, which will be mounted to a subfolder in my home folder.
I want to delete this folder later later with my technical user, but it's impossible to delete these folders without 'sudo' command, because docker will create the subfolders with different users which I don't recognize or don't have on my system:
technical@mysystem $ ls -l ~
drwxr-xr-x. 5 polkitd root 4096 Apr 21 16:18 data_1
drwxr-xr-x. 5 33 tape 4096 Apr 21 16:18 data_2
e.g.: 33 is an unknown user to my system and tape group is an unknown group (I assume they are used by docker)
technical@mysystem $ groups
technical wheel docker
technical@mysystem $ awk -F':' '{ print $1}' /etc/passwd | paste -sd " "
root bin daemon adm lp sync shutdown halt mail operator games ftp nobody systemd-network dbus polkitd sshd postfix technical
I've tried to use setuid or setgid bits on the folders, but the result is the same: when I try to delete these folders with their content written be docker I get an error and I can't do it without sudo privileges:
technical@mysystem $ rm -R data_1/
rm: cannot remove ‘data_1/myfile’: Permission denied
Questions:
- What is the proper way to handle these folders?
- How could I delete the contents of these folders (written by docker) with my
technicaluser (withoutsudoprivileges)?- What permissions should be set on the folder to be able to achieve this?
- Where to put these kind of files/project in Linux file system?
- Which best practices and patterns should I follow in this case?