Search code examples
dockerubuntu-16.04zfs

ZFS storage on Docker


I would like to try out ZFS on Ubuntu(16.04) docker container. Followed the following https://docs.docker.com/engine/userguide/storagedriver/zfs-driver/

> lsmod | grep zfs
zfs                  2813952  5
zunicode              331776  1 zfs
zcommon                57344  1 zfs
znvpair                90112  2 zfs,zcommon
spl                   102400  3 zfs,zcommon,znvpair
zavl                   16384  1 zfs

Listing the ZFS mounts

>sudo zfs list
NAME                  USED  AVAIL  REFER  MOUNTPOINT
zpool-docker          261K   976M  53.5K  /zpool-docker
zpool-docker/docker   120K   976M   120K  /var/lib/docker

After starting docker

> sudo docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.12.0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: zfs
 Dirs: 0
 ...

Wonder why I still get **Storage Driver: aufs & Root Dir: /var/lib/docker/aufs" in place of zfs?

Also how can I map "/zpool-docker" into the Ubuntu container image?


Solution

  • Assuming you have:

    • a ZFS pool (let's call it data)
    • a ZFS dataset mounted on /var/lib/docker (created with a command along the line of: zfs create -o mountpoint=/var/lib/docker data/docker)

    Then:

    Stop your docker daemon (eg. systemctl stop docker.service)

    Create a file /etc/docker/daemon.json or amend it to contain a line with "storage-driver" set to zfs:

    {
    ...
            "storage-driver": "zfs"
    ...
    }
    

    Restart your docker daemon.

    docker info should now reveal:

    Storage Driver: zfs
    Zpool: data
    Zpool Health: ONLINE
    Parent Dataset: data/docker