Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zhadowz99/9e11e9c39a053531d3c05af94692ac9a to your computer and use it in GitHub Desktop.
Save zhadowz99/9e11e9c39a053531d3c05af94692ac9a to your computer and use it in GitHub Desktop.

Install docker latest with ZFS as storage driver on Ubuntu 18.04.

Reminder before we go deep down in to the installation.

ZFS is only supported on Docker Engine - Community with Ubuntu 14.04 or higher, with the zfs package (16.04 and higher) or zfs-native and ubuntu-zfs packages (14.04) installed.

In this tutorial I'm using an aws ec2 instance with fresh installed Ubuntu 18.04 Let's get started

  1. Setup the apt package and make sure you install packages to allow apt to use https repository

    sudo apt-get update
    
    sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        gnupg-agent \
        software-properties-common
  2. Add Docker’s official GPG key:

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  3. Add the repository I'm using amd64 architecture

    sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"
  4. Install the docker engine

    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io
  5. Make sure you can run docker without sudo

    sudo groupadd docker
    sudo usermod -aG docker $USER

    After that make sure you logout from your session then login, and check the command docker

    docker system info

    Now you installed docker with overlay2 as storage driver and we gonna fix that

  6. Stop the docker service for setup the zfs storage driver

    sudo systemctl stop docker
  7. Install the zfs package

    sudo apt install zfsutils-linux
  8. Make sure you use sudo su then delete the files on /var/lib/docker

    sudo su
    sudo rm -rf /var/lib/docker/*
  9. Make sure you have a drive for the pool

    sudo fdisk -l
  10. Create a new zpool and mount it on the /var/lib/docker

    sudo zpool create -f zpool-docker -m /var/lib/docker /dev/xvdb1
  11. Configure Docker to use zfs. Edit /etc/docker/daemon.json and set the storage-driver to zfs

    sudo vim /etc/docker/daemon.json
    
    {
      "storage-driver": "zfs"
    }
  12. Start the docker service

    sudo systemctl start docker
  13. Now check the system info it should list zfs as storage driver

    docker system info
  14. Voila now you have a docker with zfs storage driver :D

Reference:

https://docs.docker.com/engine/install/ubuntu/

https://docs.docker.com/engine/install/linux-postinstall/

https://docs.docker.com/storage/storagedriver/zfs-driver/

https://ubuntu.com/tutorials/setup-zfs-storage-pool#3-creating-a-zfs-pool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment