I generally let my server do its thing, but I run into an issue consistently when I install system updates and then reboot: Some docker containers come online, while others need to be started manually. All containers were running before the system shut down.
restart: always
Host is running Ubuntu Noble
Most of these containers were migrated from my previous server, and this issue never manifested.
I wonder if anyone has ideas for what to look for?
SOLVED
The issue was that docker was starting before my NFS mount point was ready, and the containers which depended on it were crashing.
Symptoms:
journalctl -b0 -u docker
showed the following log lines (-b0 means to limit logs to the most recent boot):
level=error msg="failed to start container" container=fe98f37d1bc3debb204a52eddd0c9448e8f0562aea533c5dc80d7abbbb969ea3 error="error while creating mount source path '/mnt/nas/REDACTED': mkdir /mnt/nas/REDACTED: operation not permitted"
...
level=warning msg="ShouldRestart failed, container will not be restarted" container=fe98f37d1bc3debb204a52eddd0c9448e8f0562aea533c5dc80d7abbbb969ea3 daemonShuttingDown=true error="restart canceled" execDuration=5m8.349967675s exitStatus="{0 2024-10-29 00:07:32.878574627 +0000 UTC}" hasBeenManuallyStopped=false restartCount=0
I had previously set my mount directory to be un-writable if the NFS were not ready, so this lined up with my expectations.
I couldn’t remember how systemd names mount points, but the following command helped me find it:
systemctl list-units -t mount | grep /mnt/nas
It gave me mnt-nas.mount
as the name of the mount unit, so then I just added it to the After=
and Requires=
lines in my /etc/systemd/system/docker.service file:
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service time-set.target mnt-nas.mount
Wants=network-online.target containerd.service
Requires=docker.socket mnt-nas.mount
...
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.
Rules:
Be civil: we’re here to support and learn from one another. Insults won’t be tolerated. Flame wars are frowned upon.
No spam posting.
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it’s not obvious why your post topic revolves around selfhosting, please include details to make it clear.
Don’t duplicate the full text of your blog or github here. Just post the link for folks to click.
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
No trolling.
Resources:
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
Yep, the problem was that docker started before the NFS mount. Adding the dependency to my systemd docker unit did the trick!
Excellent, thanks for the update!