I am using Docker CE on Ubuntu 16.04, with ZFS as storage for Docker. Setup is pretty much standard:
- There's a zpool that has multiple disks
- On the zpool, there's a zfs filesystem with mountpoint
/var/lib/docker
. - Docker sees that the filesystem is ZFS, and uses that automatically
Everything works most of the time. However, once in a while when my VM boots up, the zpool fails to mount. I believe (though I am not 100% sure) that this is because the Docker service starts before the ZFS filesystem is mounted, and in fact I see a /var/lib/docker
folder created on the root FS.
How can I ensure that the Docker service does not start until all ZFS filesystems are mounted?
[Unit] Requires=zfs.target
to the docker service usingsystemctl edit docker
. Where you need a newline between[Unit]
andRequires=
. Don't know how to reflect that in a comment.zfs.target
an assurance that all the filesystems will be mounted? Rather thanRequires=
, however, shouldn't I useAfter=
? And rather than editing a unit file, I should add another one that does nothing but saysBefore=docker.service
andAfter=zfs.target.