Plex Docker starting before RCLONE mount

What is the problem you are having with rclone?

I have rcline set up as a system service, and plex in a docker. When I reboot, my plex docker loads before my drive mounts, so everything shows unavailable. Restarting plex fixes it, but is kind of a pain.

Wondering if anyone else found this, and has any solution?

What is your rclone version (output from rclone version)

1.53.1

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Ubuntu 18

Which cloud storage system are you using? (eg Google Drive)

Gsuite

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Not applicable

The rclone config contents with secrets removed.

Not applicable

A log from the command with the -vv flag

Not applicable

Hi filthyrich, so currently I run both Plex and Rclone in Docker containers as well as a number of other pieces of software that utilise the mount, such as Radarr, Sonarr, Syncthing, Mylar and Calibre etc.

With this setup I am able to use bind propagation to set my rclone mount as shared and my Plex install as a slave. I believe this would solve your problem if you were happy to put your Plex install into a docker container.

In addition as none of this software is creating directories on the mount that shouldn't already be there I am using the --allow-non-empty command in my mount script. I understand this is frowned upon in general as it will overwrite anything in it's way, however in my case this is irrelevant as the directories that are getting created before the mount aren't supposed to exist outside of the mount. This means that if Plex or any other piece of software that is dependant on the mount being available first, does create a directory too quickly it is replaced by the correct directory when the Rclone mount is ready. For my set up I have found it necessary as both Syncthing and Calibre are creating directories they expect to find instead of waiting for the mount to create them.

Please the note the above is generally not advised as you are giving the rclone mount permission to overwrite anything in its way, therefore this introduces a risk of data loss, so I wouldn't use this unless absolutely necessary.

Happy to share my scripts if you are interested? I appreciate there are many ways to skin the proverbial cat however and I'm sure others will jump in with alternative suggestions to get your setup working.

That would be awesome! A friend suggested rclone in a docker, but I couldnt get it to mount.

I use depends_on in docker-compose which also works to control startup order

How do you make depends_on check that a folder has content?

Hey @filthyrich.

So first off I don't personally use Compose for my docker setup. Although it would make my life easier, I've just not gotten around to setting it all up as I have 16 containers and it will take me a while, so my scripts are just basic docker commands. No reason you can't easily adapt them for compose though.

So here is my rclone script (This is the official rclone container)

docker run --restart=always --name rclone -e UMASK_SET=002 -e PUID=1000 -e PGID=1000 -p 5572:5572 -v /home/craftyclown/.config/Docker/Rclone/config:/config/rclone -v /home/craftyclown/.config/Docker/Rclone/logs:/logs -v /mnt:/mnt:shared -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined rclone/rclone:latest mount "RichFlixCrypt:/Encrypted/" /mnt/Skull --allow-other --allow-non-empty --dir-cache-time 1000h --log-level INFO --log-file /logs/Plex_Mount.log --poll-interval 15s --timeout 1h --umask 002 --cache-dir=/mnt/rclone_cache --vfs-cache-mode full --vfs-cache-max-size 100G --vfs-cache-max-age 336h --uid 1000 --gid 1000 --tpslimit 3 --bwlimit-file 20M --rc --rc-addr :5572 --rc-web-gui --rc-user ?????? --rc-pass ??????

As you can see it is also set up for webgui access, hence the port number but you may not want or need that. The important point to note is the volume I have added -v /mnt:/mnt:shared It is essential you add the shared command to whatever location you plan to add your mount to, not the mount itself. So in my case, as mnt/Skull is the location of my rclone mount I need to add the shared command to mnt

below is my Plex script:

docker run --restart=always --name plex -e UMASK_SET=002 -e PUID=1000 -e PGID=1000 -p 32400:32400 -e VERSION=latest -v /home/craftyclown/.config/Docker/Plex:/config -v /mnt/Skull:/mnt/Skull:rslave linuxserver/plex

as you can see I have added a volume for my mount -v /mnt/Skull:/mnt/Skull:rslave that uses the rslave command to bind itself to the mount.

Without going into great detail on bind propagation this means you are able to start Plex before the mount without issue, as Plex will see the mount once it's ready, without having to restart it.

I must just stress that the command I have in my rclone script --allow-non-empty shouldn't be used for the sake of it as it can be destructive. I am using is in my set up as I have a couple of containers that create empty directories in anticipation of where the mount should be. I have tested this in my set up and know that it does no harm, however it should be used with great caution as it gives the mount permission to write straight over the top of whatever is underneath!

Let me know if any of the above isn't clear

Docker compose example with depends_on to control plex waiting to start up. Basically the same thing as @CraftyClown run comands in compose form but he's using rslave and I'm using shared.

   rclone:
    container_name: rclone
    image: rclone/rclone:latest
    restart: unless-stopped
    user: $PUID:$PGID
    command: "mount gcrypt: /GD \
     --use-mmap \
     --allow-other \
     --user-agent=1000 \
     --dir-cache-time 1000h \
     --poll-interval 15s \
     --umask 002 \
     --cache-dir=/cache \
     --vfs-cache-mode full \
     --vfs-cache-max-size 500G \
     --vfs-cache-max-age 336h \
     --drive-chunk-size 128M \
     --log-file /logs/mount.log \
     --log-level DEBUG"
    devices: 
      - /dev/fuse 
    cap_add: 
      - SYS_ADMIN
    security_opt:
      - apparmor:unconfined
    volumes:
      - $CONFIGS/rclone:/config
      - $CONFIGS/rclone:/logs
      - $GD:/GD:shared
      - $CACHE:/mnt/cache
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
      - /etc/fuse.conf:/etc/fuse.conf:ro
    environment:
      - PUID=$PUID
      - PGID=$PGID
      - TZ=$TZ

  plex:
    container_name: plex
    image: linuxserver/plex
    restart: unless-stopped
    depends_on: 
      - mergerfs
    network_mode: host
    security_opt:
      - no-new-privileges:true
    devices: 
      - /dev/dri:/dev/dri
    volumes:
      - $CONFIGS/plex:/config
      - $MEDIA:/media
    environment:
      - PUID=$PUID
      - PGID=$PGID
      - TZ=$TZ
      - UMASK_SET=022
      - PLEX_CLAIM=xxx
      - ADVERTISE_IP=xxx

Thanks guys! I'll give this a bash on the weekend.

Are you using MergerFS in a docker too?

Check this out if you want to make a docker config: https://www.composerize.com/

Paste in your strings and it formats it all for you.

You could use the chattr command to avoid files/folders to be created in a folder before it is mounted.

chattr protect mount point

Works very well in my setup.

Also using a delay in cron using @reboot to restart containers dependent on mount points.

Not saying these are better, just chiming in with a couple of alternatives.

Yes sorry I didn't include that container as I was just trying to show depeds_on usage.

But in reality I have plex and others waiting for mergerfs, and mergerfs waiting on rclone.

Happy to share my whole docker-compose if it's useful to you. Just need to go through and sanitize some things.

How would you do it in a cron?

That's awesome! So I can make it depend on something outside of docker?

No, mergerfs is also a container. depends_on will only work on other docker containers.

Could you share your docker compose? I'm a bit lost

I use fstab to mount all rclone / mergerfs / cifs in the host OS. Some of these mounts are made available to the docker containers.
The issue I face is during power off/on/reboot. Docker starts before all mounts are ready.
So, in my case, I need to restart a container about a minute after the host OS has completed the boot process.

It's not elegant or very resilient, but it works.

My entry for this in crontab looks like this:
@reboot echo docker restart container_name | sudo at now + 1 minutes

This configuration depends on the at service which needs to be installed and enabled at boot.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.