Why Docker on a Linux Container?
Simply put – saving resources.
- Each VM in your environment has its own kernel and emulates its own hardware — CPU, RAM, disk, etc — to the guest operating system.
- If you install multiple Dockerized web applications in a VM, then you'll have to use a reverse proxy or a custom TCP port for each service.
- You may eventually require multiple VMs to host a large stack of Docker containers, which will come with slower boot speeds and more consumption of resources.
- LXC — on the other hand — do not have their own kernel, nor emulate hardware in any capacity. They share the host's kernel, using cgroups and namespaces for isolation.
- Due to the lower performance and resource overhead of LXC, you could feasibly run 1 LXC : 1 Dockerized Environment.
- This could reduce the need for complex proxy setups, since each LXC would have a unique IP address.
🚨
One major caveat to this is that Proxmox VE developers strongly recommend running Docker in VMs, as it provides greater isolation from the host and greater stability in the event of upgrades.
More on that at this Proxmox forum post and this forum post.
More on that at this Proxmox forum post and this forum post.
With all that out of the way, and you want to give Docker in LXC a try, let's proceed. Any time you want to run Docker on a Linux Container, simply repeat the steps as documented here.
✅
Using ZFS?
These steps were tested on a Proxmox node configured with ZFS and no observable issues could be detected.
These steps were tested on a Proxmox node configured with ZFS and no observable issues could be detected.
Preparing Proxmox
FUSE OverlayFS for ZFS Storage
ℹ️
fuse-overlayfs is really only required if your Proxmox node's storage backend is ZFS, as my research indicates that this is a requirement for keeping Docker volume sizes from blowing upapt clean && apt update && apt install -y fuse-overlayfsCreate a Linux Container and Test Functionality
Create the Linux Container







⚠️
Note that I have set the IPv6 setting to Static with an empty configuration to indicate that I am not using IPv6 on my container.
If you set IPv6 to DHCP and do not have a DHCPv6 server to allocate addresses, this will cause the container to stall while it tries to obtain a DHCP lease for IPv6.
If you set IPv6 to DHCP and do not have a DHCPv6 server to allocate addresses, this will cause the container to stall while it tries to obtain a DHCP lease for IPv6.


Change a Few Container Options



ℹ️
As mentioned earlier, you only need to enable
FUSE if your Proxmox storage backend is ZFS
✅
You may now start the container
Configure and Test Docker
FUSE OverlayFS for ZFS Storage on Host
ℹ️
Repeating here, once again, that you only require
fuse-overlayfs if your Proxmox node storage backend if ZFSapt clean && apt update && apt upgrade && apt install -y fuse-overlayfsInstall "fuse-overlayfs" inside LXC if host storage backend is ZFS
ln -s /usr/bin/fuse-overlayfs /usr/local/bin/fuse-overlayfsCreate symbolic link to fuse-overlayfs binary based on previous observations
Install Docker Engine on the Linux Container
Since the image I am using is Debian 11, we can follow the official Docker Engine installation instructions for Debian.
Install Docker Engine on Debian
Instructions for installing Docker Engine on Debian
apt install -y ca-certificates curl gnupg lsb-releaseInstall prerequisite packages
mkdir -p /etc/apt/keyringsMake a directory to house the Docker GPG key
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpgDownload and store the GPG key
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/nullAdd the Docker apt repository to sources
apt update && apt install -y docker-ce docker-ce-cli containerd.io docker-compose docker-compose-pluginInstall Docker packages
docker run hello-worldTest for successful installation
systemctl enable dockerEnable Docker engine to start at boot
References
Docker LXC Unprivileged container on Proxmox 7 with ZFS
I’m using Proxmox 7.0-11 on ZFS filesystem and I’m trying to use Dokku (which uses Docker) on a Ubuntu 20.04 LXC Unprivileged container. On the container, I enabled the nesting and keyctl features right after created using the Ubuntu 20.04 template. Here the config: root@srv001:~# pct config…

