kobol-wiki/docs/helios64/install/docker-zfs.md
Przemyslaw Kwiatkowski 1d2c31a15a ZFS on HDD
2020-12-21 09:21:53 +01:00

67 lines
1.8 KiB
Markdown

# Docker with ZFS pool
When you already have working ZFS pool (see [here](/helios64/install/zfs)) and want to use Docker - it is good idea to use them togeter.
## **Step 1** - Prepare filesystem
```bash
sudo zfs create -o mountpoint=/var/lib/docker mypool/docker-root
sudo zfs create -o mountpoint=/var/lib/docker/volumes mypool/docker-volumes
sudo chmod 700 /var/lib/docker/volumes
```
Optional: If you use zfs-auto-snapshot, you might want to consider this:
```bash
sudo zfs set com.sun:auto-snapshot=false mypool/docker-root
sudo zfs set com.sun:auto-snapshot=true mypool/docker-volumes
```
Create `/etc/docker/daemon.json` with the following content:
```bash
{
"storage-driver": "zfs"
}
```
## **Step 2** - Install Docker
Add `/etc/apt/sources.list.d/docker.list` with the following content:
```bash
deb [arch=arm64] https://download.docker.com/linux/ubuntu focal stable
# deb-src [arch=arm64] https://download.docker.com/linux/ubuntu focal stable
```
Proceed with installation:
```bash
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
```
You might want this:
```bash
sudo usermod -aG docker your-user
```
Voila! Your Docker should be ready! Test it:
```bash
docker run hello-world
```
## **Step 3** - Optional: Install Portainer
```bash
sudo zfs create mypool/docker-volumes/portainer_data
# You might omit the above line if you do not want to have separate dataset for the docker volume (bad idea).
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
```
Go to `http://yourip:9000` and configure.