Infrastructure & Virtualization

Running Docker on Proxmox: LXC Container vs KVM VM

Where Docker inside an LXC container breaks in production, how to build a clean Docker KVM VM on Proxmox VE, and how to prevent Docker logs from filling disk.

Almost everyone moving onto Proxmox asks the same question in week one: should Docker run inside a lightweight LXC container or inside a full Ubuntu/Debian KVM virtual machine? Online threads argue both sides endlessly, right up until a host kernel update lands and reminds everyone why the official Proxmox docs point straight at a KVM VM.

Here is where each setup works, where LXC quietly breaks, and the exact setup for both.

Why Docker inside LXC looks tempting, and where it breaks

An LXC container shares the Proxmox host kernel, starts in two seconds, and idles at a few hundred megabytes of RAM. On a single RAM-constrained home box, skipping the VM overhead feels smart.

In real day-to-day operation, three problems keep showing up:

  1. Host kernel upgrades: Small AppArmor, overlayfs, or cgroup v2 changes in a Proxmox kernel update can stop Docker inside LXC from starting until you tweak container flags.
  2. ZFS storage friction: If your LXC rootfs sits on ZFS, Docker's native overlay2 driver often falls back to vfs unless you configure fuse-overlayfs. The vfs driver copies full image layers and chews through disk space fast.
  3. Isolation tradeoffs: Some containers hit UID/GID mapping errors inside unprivileged LXC. Switching to a privileged LXC fixes the error while weakening the security boundary between container and Proxmox host.

If the box runs databases, client workloads, or anything that cannot tolerate surprise downtime during routine patching, put Docker inside a KVM VM. For a deeper look at KVM vs LXC tradeoffs, see our Proxmox LXC vs KVM guide.

Spin up a clean Ubuntu 24.04 LTS or Debian 12 Cloud-Init VM (2 vCPU, 2-4 GB RAM, VirtIO SCSI disk, QEMU Guest Agent enabled). Skip the Ubuntu snap package and install Docker directly from the official APT repository:

apt update && apt install -y ca-certificates curl gnupg
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" > /etc/apt/sources.list.d/docker.list

apt update && apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl enable --now docker

The operational payoff shows up during maintenance: you get live migration between cluster nodes, clean filesystem-frozen backups via qemu-guest-agent, and total kernel isolation from host updates.

If you still want Docker in LXC on a lab host

When RAM is genuinely tight on a non-critical test node, configure these three items upfront so you avoid the worst pitfalls:

  • Keep the container Unprivileged.
  • Under Container → Options → Features, enable both Nesting and keyctl.
  • Place the container disk on LVM-Thin if available. If it must sit on ZFS, install fuse-overlayfs inside the container and set {"storage-driver": "fuse-overlayfs"} in /etc/docker/daemon.json.

Confirm the container config (/etc/pve/lxc/CTID.conf) contains:

features: keyctl=1,nesting=1

Cap Docker log files on day one

Whether you choose VM or LXC, Docker's default json-file driver has no size limit. One chatty container will silently fill the root partition in a few weeks. Put rotation limits in place right after install:

cat << 'EOF' > /etc/docker/daemon.json
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "20m",
    "max-file": "3"
  }
}
EOF
systemctl restart docker

If you deliver pre-installed Docker servers to hosting customers, automate the base image using our Proxmox Cloud-Init template guide or provision one-click apps directly through VMRobot.