Docker creates volumes under root

  • I just got a raspberry pi 5 and I installed OMV 7 on it

    I have a HDD drive that is connected to the raspberry pi and I installed docker on


    My goal is to have a qbittorrent server and jellyfin that could access the same general volume/mount

    so I could have the following setup:


    1. download torrent to /shared/qbittorrent/downloads in the raspberry pi FS

    2. after the torrent finish downloading run a script move.sh (or something similar)

    3. depends on the file type the finished movie/show will symlink to somewhere in shared/jellyfin/movies (for example)


    that way I would could seeding the torrent for other people, but will have it for watch on my jellyfin server and structured nicely on the disk


    now I've set up the usual docker for jellyfin and qbittorrent docker images from the example in docker-compose and they are both running fine


    I tried creating a shared volume/mount named sahred/test


    by changing the docker file to be as follows:


    and tried to add a torrent for it to test


    but I got the following error:

    Code
    File error alert. Torrent: "[SubsPlease] Momochi-san Chi no Ayakashi Ouji - 09 (1080p) [633C0257].mkv". File: "/test/[SubsPlease] Momochi-san Chi no Ayakashi Ouji - 09 (1080p) [633C0257].mkv". Reason: "[SubsPlease] Momochi-san Chi no Ayakashi Ouji - 09 (1080p) [633C0257].mkv file_open (/test/[SubsPlease] Momochi-san Chi no Ayakashi Ouji - 09 (1080p) [633C0257].mkv) error: Permission denied"**


    after digging a bit I came to realize that the new shared folder is created with a different user/group ownership than the downloads or config folders


    output of ls -lhr qbittorrent

    I get the following permisisons:

    Code
    total 12K
    drwxr-sr-x 2 root root 4.0K Mar  1 20:16 test
    drwxr-sr-x 2 eyal eyal 4.0K Mar  1 20:16 downloads
    drwxr-sr-x 4 eyal eyal 4.0K Mar  1 20:16 config


    output of ls -lhr on the host machine:

    Code
    drwxrwsr-x 6 root users 4.0K Mar  1 20:19 .
    drwxr-xr-x 7 root root  4.0K Mar  1 12:50 ..
    drwxr-sr-x 6 root root  4.0K Mar  1 20:19 jellyfin
    drwxr-sr-x 5 root root  4.0K Mar  1 13:12 nginxproxymanager
    drwxr-sr-x 5 root root  4.0K Mar  1 20:16 qbittorrent
    drwxr-sr-x 3 root root  4.0K Mar  1 20:19 shared


    and inside shared on the host machine:

    Code
    drwxr-sr-x 3 root root  4.0K Mar  1 20:19 .
    drwxrwsr-x 6 root users 4.0K Mar  1 20:19 ..
    drwxr-sr-x 2 root root  4.0K Mar  1 20:19 test


    entering the docker using docker exec -it 83eb54d7967b bash

    running ls again I get (trimmed to relevant folders):

    Code
    drwxr-sr-x   2 root root  4.0K Mar  1 18:16 test
    drwxr-sr-x   2 root root  4.0K Mar  1 18:16 temp
    drwxr-sr-x   2 abc  users 4.0K Mar  1 18:16 downloads
    drwxr-sr-x   4 abc  users 4.0K Mar  1 18:16 config


    which means the test folder is created as root instead of abc:users

    and I don't understand why this is happening


    this is my jellyfin docker file:


    I know I can probably used chown and maually change the user/group of the folders

    but for some reason it feels to me like the wrong approach to fixing this problem


    is there something that I'm doing wrong?

    also is my approach to having shared volume between jellyfin and qbittorrent is correct?

    is there a better way to approach it?

  • tldr; simplify.


    For now I can tell you that the PUID and PGID are simply suggestions to the container. If you use sudo with the .yaml, then the container does run as root.


    So, inside the container, everything is running as root. If inside the container it makes the directory "/foo/bar", then it is natively root's directory. If the PUID/PGID are to be changed, then it is up to the script in the container to apply those. If the script doesn't do it, then it doesn't do it :-/. Regardless, your idea of doing it yourself is the bulletproof answer.


    As an example, this is atop of one of the files in gderf's qbtittorrent container, notice how the script does it manually (just like you would externally).


    Code
    # Set the rights on the /downloads folder
    find /downloads -not -user ${PUID} -execdir chown ${PUID}:${PGID} {} \+
  • My goal is to have a qbittorrent server and jellyfin that could access the same general volume/mount

    Use the same UID:GID on both YMLs


    Make several folders on the disk that you want the files to be.

    A main folder named media

    Several under it named (for eg) anime, shows, movies


    You need to make them owned by the UID:GID of the YMLs.


    For eg UID=1000, GID=100


    mkdir -p /srv-dev-disk-by-uuid-xxxxxxyyyy/media/anime

    mkdir -p /srv-dev-disk-by-uuid-xxxxxxyyyy/media/shows

    mkdir -p /srv-dev-disk-by-uuid-xxxxxxyyyy/media/movies

    chown -R 1000:100 /srv-dev-disk-by-uuid-xxxxxxyyyy/media


    Now use those volumes on both services.

    When adding a torrent to qbit, if you download it to the default, it will stay on the downloads folder and jellyfin won't see it.

    All you need is to change it's location on the qbit GUI to the corresponding subfolder:


        


    Just make sure you write the path that is INSIDE the container and NOT the full HOST path.


    See my examples for qbit.

    INSIDE the container, the path is /media but, in fact, is /srv-dev-disk-by-uuid-xxxxxxyyyy/media on the host.

    Code
        environment:
          - PUID=1000
          - PGID=100
    --------------
        volumes:
          - /srv-dev-disk-by-uuid-xxxxxxyyyy/media:/media
          - /appdata/qbittorrent/config:/config
          - /srv-dev-disk-by-uuid-xxxxxxyyyy/downloads:/downloads


    My jellyfin example:

    Code
        environment:
          - PUID=1000
          - PGID=100
    ---------------------
        volumes:
          - /appdata/jellyfin/config:/config
          - /srv-dev-disk-by-uuid-xxxxxxyyyy/media/shows:/data/tvshows
          - /srv-dev-disk-by-uuid-xxxxxxyyyy/media/movies:/data/movies
          - /srv-dev-disk-by-uuid-xxxxxxyyyy/media/anime:/data/anime


    Why the 3x volumes on Jellyfin?

    To create the Libraries in seperate.

  • When adding a torrent to qbit, if you download it to the default, it will stay on the downloads folder and jellyfin won't see it.


    If I keep the torrent downloaded into /downloads inside the container and have the script symlink from /downloads inside the container into /media/anime for example


    Would jellyfin still be able to see the file?


    Edit 2: Jellyfin doesn't even recognize files I copy over ssh into media/anime

    folder but playing them over ssh works fine



    Edit: I tried both approaches

    but it seems that jellyfin can't recognize either symlink or downloading directly to the media folder


    for symlink the owner is root:users and when directly downloading to media it's eyal:users on the host machine (abc:users on the containers)


    tried both MKV and mp4 file format in change the format was the issue



    Jellyfin dockerfile:


    Code
        environment:
          - PUID=1000
          - PGID=100
        volumes:
          - CHANGE_TO_COMPOSE_DATA_PATH/jellyfin/library:/config
          - CHANGE_TO_COMPOSE_DATA_PATH/media/lives:/data/lives
          - CHANGE_TO_COMPOSE_DATA_PATH/media/anime:/data/anime


    qtbittorrent dockerfile:

    Code
        environment:
          - PUID=1000
          - PGID=100
          - TZ=Etc/UTC
          - WEBUI_PORT=8080
        volumes:
          - CHANGE_TO_COMPOSE_DATA_PATH/qbittorrent/config:/config
          - CHANGE_TO_COMPOSE_DATA_PATH/qbittorrent/downloads:/downloads
          - CHANGE_TO_COMPOSE_DATA_PATH/media/:/media


    ls -lha on the data_path:

    Code
    drwxrwsr-x 6 root users 4.0K Mar  1 21:40 .
    drwxr-xr-x 7 root root  4.0K Mar  1 12:50 ..
    drwxr-sr-x 3 root root  4.0K Mar  1 21:40 jellyfin
    drwxr-sr-x 4 eyal users 4.0K Mar  1 21:37 media
    drwxr-sr-x 5 root root  4.0K Mar  1 13:12 nginxproxymanager
    drwxr-sr-x 4 root root  4.0K Mar  1 21:40 qbittorrent
    eyal@homepi5:/srv/dev-disk-by-uuid-0d441b50-e8a1-418d-9


    ls -lha in media:

    Code
    drwxr-sr-x 4 eyal users 4.0K Mar  1 21:37 .
    drwxrwsr-x 6 root users 4.0K Mar  1 21:40 ..
    drwxr-sr-x 2 eyal users 4.0K Mar  1 21:48 anime
    drwxr-sr-x 2 eyal users 4.0K Mar  1 21:36 lives


    ls -lha in qtbittorrent:


    Code
    drwxr-sr-x 4 root root  4.0K Mar  1 21:40 .
    drwxrwsr-x 6 root users 4.0K Mar  1 21:40 ..
    drwxr-sr-x 4 eyal users 4.0K Mar  1 21:40 config
    drwxr-sr-x 2 eyal users 4.0K Mar  1 21:46 downloads

  • Thank you for your answer

    I guess there's no way to avoid manually chowning

  • f I keep the torrent downloaded into /downloads inside the container and have the script symlink from /downloads inside the container into /media/anime for example


    Would jellyfin still be able to see the file?

    You don't need to leave them inside downloads nor link it to jellyfin.

    Just by changing the location, the file will be seen on jellyfin and still being seeded on qbit.


    If you stop seeding, the file will still be seen on jellyfin.

    If you remove the torrent from qbit (NOT the files but just the torrent), jellyfin will still see the file.


    This was the most simple way I found to prevent issues with permissions.


    If you want to simplify, create categories on qbit that automaticaly move the file (depending of what you selected) to the specific folder

    Right click on Categories-> All-> +Add Category



    Add a torrent and set it to Automatic Mode and select the proper Category

    When the torrent finishes downloading, it will move to the proper place.



  • Thank you, I think I fixed minor issues

    and now your setup is working, and jellyfin recognize the torrents I download to media/anime


    I wanted symlink since I also planned on adding rss feeds to qbit

    and I for some torrents in the rss I can't (I think) set different categories while it automatically downloads, you can only assign single category to the whole rss feed


    but in qbit you can set a script to run when a torrent finishes

    so I wanted the script to symlink and do the folder organization in jellyfin for me


    Edit: apparently it works with hard links and not symbolic links, and since hard links also doesn't disk space it works for my plans if I'll need to


    so I have your solution and mine working both working


    Thank you again for your help

  • eyalmazuz

    Added the Label resolved
  • eyalmazuz

    Added the Label OMV 7.x (RC1)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!