I have a container which won’t start when a volume path is missing (e.g. network path not found)
Until now I’ve been commenting in/out the offending path when it is/isn’t accessible but there must be a better way - would someone be kind enough to point me to a better solution?
Brainstorming, I’m thinking:
Symbolic link(s)
Separate linked container (possible?)
Dynamic/hotswappable volume paths (possible?)
Just reading through docs so hopefully some of these thoughts are possible
First of all: you don’t use volumes, you use bind-mounts.
Bind-mounts are using “mount --bind /src/path /target/path” (you can test its behavior on any linux system right away) . Whenever you map a host path (regardless wether its a folder on disk, a mountpoint for a drive, a mountpoint for a remote share) into a container path, the host path will be mounted into the container path. If you dismount/re-mount a drive or remoteshare on the host, the handle for the mount will change, but the container will still point to the old handle. Though, if you bind-mount the parent folder of the mounted drive or network share into the container, you could probably leverage bind propagations to make it work.
Since you already used bind-mounts from the beginning, do you mind sharing the exact solution?
If you only switched to mount the parent folder without specifying the correct mount propagation, the problem of “stale” submounts might still effect you. Which mount propagation did you finaly use?
In the volume declaration of app, the first two entries are the long and short syntax for volumes, both have a matching volume declaration underneath the top level section volumes and are listend when docker volume ls is executed. A volume will copy pre-existing content in the container folder back into the volume (unless you configure it to not do so). Some images rely on this mechanism!
The third and forth entries are the long and short syntax for bind-mounts - no matching declartion in the volumes top level section, not listed with docker volume ls. A bind-mount “replace” the target folder in the container, without copying pre-existing data from the container back to the bind-mount.
To make confusion perfect, it is also possible to declare a volume baked by a bind (last two entries). It would be listed with docker volume ls as well. These volume provide the copy pre-existing data mechanism as well.
After having this sorted out, I am even more confused about what actualy brought the solution… Was it just mounting the parent folder?
Perhaps I wasn’t in the right head space at the time but I felt like I sank a whole evening into trying to understand Docker data storage before our last interaction, and I still didn’t grok it properly. I think I understand it a bit better now.
Firstly, I now acknowledge I was never using docker volumes, as you mention, and was using docker bind mounts all along
Secondly, because I updated my bind mount syntax to the long syntax and specified read_only: true I think this fixed my issue
Lastly, I’m going to read the manage app data docs again but if I don’t understand something would you be willing to help?
In case of trouble, prep your case and post it If the level of provided details is sufficient and the desired outcome is something that sparks my interessent, then I usualy pitch in.
Though some topics realy don’t spark my interesst: like MACVLAN network, systemd, ui-applications, VPN client containers, genereally things that result in anti-patterns.
Months ago I came to the conclusion that his forum is headless. I would be surprised, if someone is going to respond.