File sharing from NAS to unprivledged containers #2044
Replies: 3 comments 6 replies
-
Great writeup @zelig2 , thanks! You seem knowledgeable about grouping and permissions, which I am trying to learn. I might try to copy this setup, but do you know of a easier way to get the right permissions on the folders that are mounted if all the users are root? |
Beta Was this translation helpful? Give feedback.
-
Hi @zelig2 I am facing issue with providing access to root user or another user access to an unprivilige dockge container, I have installed dockge unpriviliged container and added the following lxc id mapping but the mount is still showing under nogroup nobody access. Can you please help me with it? my user uid and gid is 1000, checked it from /etc/passwd file and nobody group is 65534 lxc conf
subuid
subgid
|
Beta Was this translation helpful? Give feedback.
-
@zelig2 Thank you for the write up. I believe this is the most comprehensice write up I've found that should get me to where I need to be. Unfortunately, I've tried so many things already that I am a little apprehensive to change much. I am stuck on the 2nd step. Where you create a bunch of users on the host (pve) and then mention the below but don't mention how the new users are supposed to be written in - (sonarr:1502:100).
I am also not sure where the root:1500:100 came from and how it relates to what we're doing. Sorry if this is something super simple that is just going over my head. Thank you, again! |
Beta Was this translation helpful? Give feedback.
-
Originally, all my *arr services were installed on a Synology NAS as Docker containers. Over time I found the updating process and stability to be lacking on the NAS so I wanted to move them over to my Proxmox cluster to help with future upgradability and maintainability. Each service is its own LXC on my cluster and thus each has its own Container ID. For my set up I have Plex @ 501, Sonarr @ 502, Radar at 503, Prowlarr @ 504 and Sabnzbd @ 505.
Sonarr was the first system to move over to Proxmox and resulted in multiple weeks of figuring out a good way for me to do permissions. Probably the best one to try because it had sonarr running from a non-root user, which ultimately I preferred.
Step 1: configure NAS
I found using SMB was the most ideal for this configuration as I could control who had access to what files as well as more easily see when a client messed up. So for your NAS make sure there's a specific user for each service you want to have access to the media/download files.
Step 2: create a specific *arr users on the host.
For each user I made the UID as 1+LXC_ID which will allow me to mount the network share for these users. The command
id sonarr
at the end will confirm the user name gets the right UID as well as the same GID. Repeat this for all the other users (radarr, prowlarr, sabnzbd, etc). Note: this likely won't work if containers need to move to a different node in a cluster.Next, add a line in
/etc/subuid
and/etc/subgid
to account for these new users created above.Then with the new home folder created for
sonarr
I store a credentials file to be used by the CIFS/SMB mount as detailed here./home/sonarr/.cifs_creds
After the file has been created I changed the ownership and rights:
Do this for all newly created users.
Step 3: remote folder mounting
Next I needed to mount the remote folder from my NAS to the Proxmox host, but unfortunately I couldn't use the Proxmox GUI as I needed the specific user I just created to own the files. I used the guide from here to help generate the right script to update the fstab so the mount will be automounted each time. The below example shows mounting the
//NAS/video
folder but using the sonarr credentials. I then did this same thing again for every arr container that needed access to that folder. It's very redundant but then I can tell which arr user is mucking around with the files if something should go wrong. I then also have a local SSD drive that I have adownloads
folder in there that is owned by sabnzbd:sabnzbd.Now that we have fstab updated we have to mount the folder. These commands assume no folder exists currently.
Do this for every mount point you create like
radarr-video
, etc.Step 4: Sonarr container (ID 502)
Now everything is ready to go on the host so we need to create the LXC with the service. As always, go to TTeck's Helper Scripts to get the right script for creating the LXC. After installing Sonarr stop sonarr before making all these changes.
For sonarr, the main program is run by a non-root user, sonarr:sonarr which has the IDs of 103:1000. We want to map that LXC user to the host sonarr:sonarr user. This is done through binding. Then we also need to map the NAS folder into the container. User 1505 is for mapping of the download folder owner
sabnzbd
. Edit the configuration file located at/etc/pve/lxc/502.conf
on the host and add this to the end of the file:Any time a change is made to the configuration file you'll need to reboot the container to get the changes to show up.
Sonarr User Updates
Add user sabznbd to each LXC as there is a directory to be shared across all the arrs for downloads. Then I also added the local arr user to the sabnzbd group for file access.
Sonarr folder locations and ownerships
For my specific case, I want my backup files of sonarr to be pointing to the same directory locations in this container when I restore from backup. In order to do that I need to make a symbolic link to the actual folders with the right ownership. That's why the media needs to be in
/video
. Otherwise you could point your sonarr to the specific/mnt
folder.There's a chance that some of the sonarr directories will end up with the wrong ownership. Especially if sonarr was originally run as root. To fix this problem you can run the following
chown
commands:Sonarr.service update
Noting for reference that tteck wants to change from sonarr:sonarr user to root:root in the container. I don't want that so here are the notes to get it back if an update breaks everything.
/lib/systemd/system/sonarr.service
Restart Sonarr
After all the changes you can restart sonarr. I would also suggest rebooting the container to ensure everything is working properly.
Step 5: Radarr container (ID 503)
After installing Radarr from tteck's Helper Scripts then stop radarr before making all these changes.
I want to get radarr running from a specific user:group and not root:root. Edit
/etc/systemd/system/radarr.service
:Need to create the specific user and group in the container and also change the ownership of the radarr config files:
Other than sonarr, I am going to keep 1500:1500 as the internal UID:GID as well as including the sabnzbd user. The updated 503.conf file on the host looks like this now and will be similar for the other arrs:
Radarr folder locations and ownerships
Tailor this just like you might have needed to in the sonarr section above.
Step 6: Sabnzbd container (ID 505)
I only need to mount the downloads directory. I originally tried having the download directory on the NAS and it resulted in two additional copies of the file moving around the network which really slowed things down unnecessarily. So I changed to using an internal SSD which drastically sped up post-processing. Need to share a downloads folder across all the LXCs. This is a little different so I've added a sabnzbd user to all the LXCs and mapped it back to the host. Then added the local user to the sabnzbd group.The local download directory needs to be shared and accessible by all arr containers.
In the other LXCs run these commands (change radarr below):
Step 7: Prowlarr container (ID 504)
No remote folder mounting is needed for prowlarr so you can skip all the crazy user binding or folder mapping if you like. I the user binding so I can see the prowlarr user easily in a
ps -aux
command on the host. But it's really not needed. I created a prowlarr user on the LXC so I editedprowlarr.service
like in the radarr container section above.Error fixing:
I had to fix an ownership issues during this process (likely from not stopping the arr service before mucking around). I needed to end up mounting the file system on the host and changing permissions there because the LXC was kicking an error to change the owner of a number folders.
Beta Was this translation helpful? Give feedback.
All reactions