If you want to use Docker with Proxmox you have 3 options: run Docker in VM, run Docker in LXC, or run Docker directly on the PVE node. Here it small tutorial for the 3rd option.
Note: Everything to be run as root.
Enable firewall in PVE GUI (on at least datacenter level). Even if you do not use firewall in Proxmox you must enable it (just set default policy to ACCEPT), because Docker will use netfilter.
Prepare iptables for Docker:
You must make the above setting permanent. For example edit
Note: Possibly there are better ways to achieve it, but the above "works for me"...
Prepare filesystem - more or less this way:
If you use zfs-auto-snapshot, you might want to consider this:
Create
Add
Install Docker:
You might want this:
Voila! Your Docker should be ready! Test it:
Option: Install Portainer
You might omit the 1st line if you do not want to have separate dataset for the docker volume (bad idea).
Go to http://yournode:9000 and configure.
Note: Everything to be run as root.
Enable firewall in PVE GUI (on at least datacenter level). Even if you do not use firewall in Proxmox you must enable it (just set default policy to ACCEPT), because Docker will use netfilter.
Prepare iptables for Docker:
Code:
iptables -N DOCKER-USER; iptables -I DOCKER-USER -j ACCEPT
You must make the above setting permanent. For example edit
/etc/network/interfaces
and add it to the "lo" interface as pre-up script:
Code:
auto lo
iface lo inet loopback
pre-up iptables -N DOCKER-USER; iptables -I DOCKER-USER -j ACCEPT
Prepare filesystem - more or less this way:
Code:
zfs create -o mountpoint=/var/lib/docker rpool/docker-root
zfs create -o mountpoint=/var/lib/docker/volumes rpool/docker-volumes
chmod 700 /var/lib/docker/volumes
If you use zfs-auto-snapshot, you might want to consider this:
Code:
zfs set com.sun:auto-snapshot=false rpool/docker-root
zfs set com.sun:auto-snapshot=true rpool/docker-volumes
Create
/etc/docker/daemon.json
with the following content:
Code:
{
"storage-driver": "zfs"
}
Add
/etc/apt/sources.list.d/docker.list
with the following content:
Code:
deb [arch=amd64] https://download.docker.com/linux/debian buster stable
# deb-src [arch=amd64] https://download.docker.com/linux/debian buster stable
Install Docker:
Code:
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 -
apt update
apt install docker-ce docker-ce-cli containerd.io
You might want this:
Code:
usermod -aG docker your-user
Voila! Your Docker should be ready! Test it:
Code:
docker run hello-world
Option: Install Portainer
Code:
zfs create rpool/docker-volumes/portainer_data
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://yournode:9000 and configure.
Last edited: