Hi, hope everyone’s good.
I’m trying to set up qBittorrent using the linuxserver.io Docker container so its downloads are only accessible to certain users on the host system. I’m using Docker Desktop on Debian 12.
I’ve tried what I thought was the correct setup, but it’s not working. Any tips would be appreciated.
Details:
The logged-in user on my host is 1000:1000, and the host user I want to own the downloads directory is 1007:1006.
In the docker-compose file I’ve tried passing the PUID and PGID (1007 and 1006) to the container and allowing it to create the downloads directory on the host when I first start the container, but the mapped downloads directory is created with 1000:1000 as the owner.
This is my docker-compose file:
services:
qbittorrent:
image: lscr.io/linuxserver/qbittorrent:latest
container_name: qbittorrent
network_mode: container:gluetun
environment:
- PUID=1007
- PGID=1006
- TZ=Etc/UTC
- WEBUI_PORT=8080
- TORRENTING_PORT=6881
volumes:
- /home/user/Data/Docker/appdata/qBittorrent:/config
- /home/user/Temp/qBittorrent:/downloads
restart: unless-stopped
Both the /config and /downloads directories are created on the host when I first start the container:
/home/user/Data/Docker/appdata/qBittorrent
/home/user/Temp/qBittorrent
There are no error messages when I start the container, and I can successfully download a torrent which is saved in the downloads dir.
But, both created directories (and the downloaded files) are owned by 1000:1000. Showing the downloads dir owner:
stat /home/user/Temp/qBittorrent
File: /home/user/Temp/qBittorrent
Size: 0 Blocks: 0 IO Block: 4096 directory
Device: 0,41 Inode: 11998077 Links: 1
Access: (0755/drwxr-xr-x) Uid: ( 1000/ user) Gid: ( 1000/ user)
If I stop the container, then change the owner of the downloads dir:
sudo chown -R 1007:1006 /home/user/Temp/qBittorrent
the owner looks correct:
stat /home/user/Temp/qBittorrent
File: /home/user/Temp/qBittorrent
Size: 0 Blocks: 0 IO Block: 4096 directory
Device: 0,41 Inode: 11998077 Links: 1
Access: (0755/drwxr-xr-x) Uid: ( 1007/qbittorrent) Gid: ( 1006/ misc)
But then when I restart the container and try to download another torrent, the torrent errors with this log message:
File error alert. Torrent: "Tears of Steel". File: "/downloads/Tears of Steel/Tears of Steel.webm". Reason: "Tears of Steel file_open (/downloads/Tears of Steel/Tears of Steel.webm) error: Permission denied"
What am I missing here? How can I get the qBittorrent container to create files in the mapped host directory with the correct permissions?
Thanks in advance for any help!