docker, systemd and nfs walked into a bar...

So I recently had some power issues and realized that things were not starting up in the correct order. I'm sure most people have figured this out, but I wanted to put it here for my own well being.

First, make sure that your fstab file is correct for your nfs mounts.

x.x.x.x:/mnt/thunder/audio /mnt/nas/audio nfs rw,intr,nfsvers=3,x-systemd.automount 0 0
x.x.x.x:/mnt/thunder/video /mnt/nas/video nfs rw,intr,nfsvers=3,x-systemd.automount 0 0
x.x.x.x:/mnt/rain/docker   /docker        nfs rw,intr,nfsvers=3,x-systemd.automount 0 0 

Then we need to make sure things start up in the right order. For docker, I added...

vim /etc/systemd/system/

... snip ...
BindsTo=containerd.service firewalld.service containerd.service
Requires=docker.socket containerd.service docker.mount mnt-nas-audio.mount mnt-nas-video.mount

... snip ...

To find what your mount names are, you can run the following command.

systemctl list-units | grep /mnt

This should make it where the fstab mounts will mount automatically, and then the docker service (or any service you wish) will only start after the successful nfs mount.

No comments:

Post a Comment