I'm facing an issue with my setup where most of my data is stored on a NAS while my Docker containers run on a different server in the same LAN. I've mounted an SMB share from the NAS on the Docker host, and it works great for containers that need access to that data, like photos and media. However, the problem arises when the NAS isn't available during container startup, which causes the Docker containers to fail to start. Since my NAS isn't online 24/7 but my Docker server is, I'm looking for a way to have the containers start even when the SMB share is offline, and then automount the share when it becomes available—similar to how the x-systemd.automount works in Linux for SMB mounts. Any advice? Thanks!
4 Answers
I’m not sure why you’d want to start the container without the NAS available. If the container relies on the mounted share, you might end up with inconsistent data. If the mount isn’t available but the container starts, what behavior would you expect?
You could write a bash script that checks the availability of the mount point at regular intervals. This script could manage starting different sets of containers based on whether the share is accessible or not. Unfortunately, Docker itself doesn’t handle this situation automatically, so a workaround like this is needed.
Nope, Docker requires the mounts to exist when the container starts. If the shared resource isn’t available, the container won’t launch.
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures