What causes docker to umount zfs-based /var/lib/docker/volumes?

I setup docker and installed some containers. I have a backup of these containers’ volumes in a zfs filesystem. I shut docker down and mounted the zfs filesystem to /var/lib/docker/volumes and restarted docker. Docker unmounted the filesystem preventing the containers from running! Why is this happening?

I am not sure about the reason, but you should never touch the files inside the docker data root. You can move the entire docker data root to a mounted filesystem if that filesystem is supported or just use bind mounts to mount a speciific folder from your host instead of using local volumes.

The supported backing filesystems can be found in the documentation:

https://docs.docker.com/storage/storagedriver/select-storage-driver/#supported-backing-filesystems

zfs backing filesystem requires the zfs storage driver, although the volume folder is not so much different from a bind mount, that is why I say I don’t know the reason, but Docker could check i’ts data root and fix it if it is not correct.

I had /var/lib/docker under btrfs and /var/lib/docker/volumes as zfs and that confused docker. It wants the entire tree under the same filesystem apparently. Once I did that, I was able to see my zfs mount to /var/lib/docker/volumes.

This turns out not to work either. It seems it’s not possible to reliably put mounts under /var/lib/docker. The only solution is to move the docker data root as described IBM Documentation