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

I can’t find any option to restore just the settings. 1710356648 Phew, managed to fix it. Within the...
Replies
4
Views
390
  • Question
Open an issue on that GitHub page. The developers will be glad to assist. OP has posted two threads on...
Replies
5
Views
962
I'm happy with email notifications but in v0.3.3 of dockcheck the author added apprise notifications...
Replies
4
Views
1,041
Looks like I triggered you somehow with my post: it was not my intention. I have no idea whether bash or...
Replies
4
Views
1,532
I have no idea what you are doing, but I just tested it based on the instructions of the guide you linked...
Replies
11
Views
2,588
True! Still, there are certain containers that can be run on those machines as long as users are aware of...
Replies
8
Views
4,391
Who's this 'support' you're talking about? Did you miss the 'unoffical' bit in this? Or the 'NAS owners'...
Replies
9
Views
2,991

Welcome to SynoForum.com!

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

Registration is free, easy and fast!

Back
Top