Docker container that depends on share

Currently reading
Docker container that depends on share

so - I have two synology boxes - lets call them A and B. A is the fastest processor I could get - B is just extra storage, so the slowest.

so I run a bunch of docker containers on A, have a mount to B - and all works well.
Until the machine restarts.
What happens is that the docker container fires up before the share does - or without causing the mount to happen. For a while they would start up pointing to the directory behind the mount, which is the worst possible option - but I changed that to point each docker container to a directory under the mount, so they will just fail if the volume mapping isn't present.

But this means, if I restart, or the power goes out - which is depressingly frequent - the docker containers don't start.

Is there any way to force the mount to happen before the docker containers, or alternatively have them wait until the mount is present before trying to start?
 
Last edited:
There is a way, but its high likely you won't like it :D
It will require you to manage those containers either from the cli or portainer.

Both allow to create named volumes that can point either to nfs or cifs shares (for the sake of simplicity and reliability nfsv4 is recommended!). Then when the container is created, it needs to use the named volume and moint it into the container path (instead of bind mounting a host path into the container path - that's what the Syno UI does).

If a named volume baked by a remote share is used, the container will fail and restart the container until it succeeds - that is if the restart policy always is used.

Appart of that there might be ways to leverage inotify to start/stop a container. Though, I am not entirely certain if a mount indeed triggers an inotify event.

Note: the cli/portainer also alows to set mount propagation for bind mount volumes, which indeed would propagate the mount state into the container, but it would not solve the issue that the container will see the unmounted host path when the remote share is not mounted. Without mount propagation, the container will see whatever state the folder had when the container was started...
 
Upvote 0

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

  • Question
Hi, Thanks for sharing. Hope this will work. Best regards
Replies
2
Views
421
I was trying to set up ntopng but the strangest thing happened, as I am not able to get an IP address. Is...
Replies
10
Views
1,952
  • Question
One-eyed-king, thank you very much for the answer. I have attached screenshots of the Syno GUI settings...
Replies
2
Views
629
  • Solved
All setup now and working great, thanks again for your help (y)
Replies
3
Views
964
🍪 🍺 🍪 🍺 🍪 🍺 Major embarrassment... I should have caught this from @Rusty 's comment. In my docker...
Replies
10
Views
2,057
DSM 7 - and tht's what I'm trying to figure out how to do - can't see any option to run it as root...
Replies
3
Views
1,715
good question /marked! I have been long seeking for setting up a e.g. CUPS printer server, e.g .AirPrint...
Replies
3
Views
3,628

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Trending threads

Top