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

Looks like I triggered you somehow with my post: it was not my intention. I have no idea whether bash or...
I have no idea what you are doing, but I just tested it based on the instructions of the guide you linked...
True! Still, there are certain containers that can be run on those machines as long as users are aware of...
Who's this 'support' you're talking about? Did you miss the 'unoffical' bit in this? Or the 'NAS owners'...
I heard back from Synology support, this functionality is not available. The support rep has filled a...
done. everything works as expected. Thanks for help @Rusty and @Telos
I've done the MACVLAN setup with Portainer/Docker, so I get the gist of what you are saying, there is...

Welcome to! is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Trending threads