Docker on Proxmox: in a VM or in an LXC container?
You have a Proxmox host and a Docker Compose app. You can run Docker inside a full virtual machine (KVM) or inside an LXC container. We built both, side by side, on the same host with the same budget, ran the same app in each, and measured. This page shows what we did, what we measured, and what went wrong on the way.
Tested on
- Proxmox VE 8.4.21, kernel 6.8.12-43-pve, ZFS 2.2.10 (
local-zfs, the installer default) - Host: 2x Intel Xeon E5-2697 v2 (48 threads), 503 GB RAM. A busy host (about 60 other VMs running), so every test was run 3 times, alternating VM and LXC, and we report the middle value (the median).
- Setup steps were also run on a second, older Proxmox 8.4.21 host (2x Xeon X5550, "dir" storage on spinning disks).
- Both guests: Debian 12, 2 vCPU, 2048 MB RAM, no swap, 16 GB disk.
VM: Debian 12 "genericcloud" image,
cpu: host, VirtIO SCSI, cloud-init. LXC:debian-12-standard_12.12-1, unprivileged. - Docker Engine 29.9.3 and Docker Compose v5.7.1 from Docker's own apt repository, the same version in both.
- The app: nginx (
nginx:stable-alpine), PostgreSQL 16 (postgres:16), and a small Alpine container with the load tools (wrk,fio). - Date: November 2026.
The short answer
- The LXC was cheaper and faster in everything we could measure fairly: about 1/6 of the host RAM at idle (104 MiB vs 664 MiB), up and serving in 6.8 s instead of 16.4 s, 28% less host disk, and 59% more web requests per second on the same 2 CPUs.
- The VM is the one Proxmox recommends for Docker, and it is the safer choice: it has its own kernel, so the app cannot need (or break) anything on the host; it can be live-migrated; and Docker in it works with no special settings.
- Docker in an LXC needs
nesting=1. Without it, Docker installs but no container starts. - We could not measure database and disk speed fairly on our busy shared host (see What went wrong, item 6), so this page has no database or disk numbers. Do not read "faster" above as "faster at everything".
What we expected (written before testing)
- The LXC uses far less RAM.
- The LXC starts several times faster (under 5 s; the VM 15-30 s).
- The LXC uses less disk.
- Web and database speed are within 10-15% of each other; disk writes are slower in the VM.
- Docker does not work in a default LXC until "nesting" is on, and something else will still be odd.
- The LXC shares the host's kernel; the VM has its own.
How each one turned out is in Results.
Build the VM
# Example IDs and names: VM 201, storage local-zfs, bridge vmbr0. Use your own.
qm create 201 --name docker-vm --memory 2048 --balloon 0 --cores 2 --cpu host \
--scsihw virtio-scsi-pci --ostype l26 --agent 1 --serial0 socket --vga serial0 \
--net0 virtio,bridge=vmbr0 \
--scsi0 local-zfs:0,import-from=/var/lib/vz/template/debian-12-genericcloud-amd64.qcow2 \
--boot order=scsi0 --ide2 local-zfs:cloudinit \
--ipconfig0 ip=dhcp --ciuser debian --sshkeys ~/.ssh/id_ed25519.pub
qm disk resize 201 scsi0 16G
qm start 201
The Debian cloud image does not include qemu-guest-agent or nftables. Install them yourself (or with a
cloud-init packages: list) if you want the guest agent or a firewall.
Build the LXC
# Example ID 202. The template comes from: pveam update && pveam download local debian-12-standard_12.12-1_amd64.tar.zst
pct create 202 local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst \
--hostname docker-lxc --unprivileged 1 --features nesting=1,keyctl=1 \
--cores 2 --memory 2048 --swap 0 --rootfs local-zfs:16 \
--net0 name=eth0,bridge=vmbr0,ip=dhcp --ssh-public-keys ~/.ssh/id_ed25519.pub
pct start 202
The important line is --features nesting=1. Without it, Docker installs and the Docker service starts, but no
container will run (see What went wrong, item 1).
- The web UI's "Create CT" wizard ticks Nesting for you when the container is unprivileged (we checked the
Proxmox 8.4 web UI code: the box defaults to on).
keyctlis not set by the wizard. pct createon the command line turns on neither. If you script your containers, add--features nesting=1.- Proxmox's own help text for
keyctlsays it "is required to use docker inside a container". With Docker 29.9.3 and this app we turned keyctl off again (nesting only) and everything still worked:hello-world, all three services, the web page, the database,docker exec, no errors in the journal. Turn it on if something fails with a keyring orkeyctlerror; we did not need it.
Install Docker (same in both)
apt-get update && apt-get install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" \
> /etc/apt/sources.list.d/docker.list
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
docker run --rm hello-world
docker info, side by side:
| VM | LXC | |
|---|---|---|
| Kernel | 6.1.0-54-cloud-amd64 (its own Debian kernel) | 6.8.12-43-pve (the host's kernel) |
| Storage driver | overlayfs (containerd snapshotter) on ext4 | overlayfs (containerd snapshotter) on ZFS |
| Security options | apparmor, seccomp, cgroupns | seccomp, cgroupns (no AppArmor inside) |
| Cgroup | v2, systemd driver | v2, systemd driver |
Overlayfs on ZFS works because ZFS 2.2 and later support it. Older guides that say "Docker in an LXC on ZFS needs
the vfs driver or a separate ext4 volume" were written for older ZFS.
The test app
services:
web:
image: nginx:stable-alpine
ports: ["8080:80"]
volumes: ["./site:/usr/share/nginx/html:ro"] # one 10 KB HTML page
restart: unless-stopped
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: example-only
volumes: ["dbdata:/var/lib/postgresql/data"]
restart: unless-stopped
bench:
build: ./bench # FROM alpine:3 / RUN apk add --no-cache wrk fio curl
command: ["sleep", "infinity"]
volumes: ["benchdata:/data"]
restart: unless-stopped
volumes:
dbdata: {}
benchdata: {}
How we measured (3 runs of each, alternating VM and LXC, median reported):
| Test | Command |
|---|---|
| Web | docker compose exec bench wrk -t2 -c50 -d30s http://web/ (the load tool runs on the same guest, so both share the same 2 CPUs: this measures the guest, not the network) |
| Database | pgbench -i -s 20 once, then pgbench -c8 -j2 -T30 |
| Disk, small random writes | fio --rw=randwrite --bs=4k --size=1G --direct=1 --ioengine=libaio --iodepth=16 --runtime=30 on a Docker volume |
| Disk, big sequential writes | same with --rw=write --bs=1M --iodepth=4 |
| Start time | from the Proxmox host: guest fully off, qm start / pct start, then poll the web page until it answers |
| RAM | from the Proxmox host, 60 s after the app is up: the VM's qemu process RSS; the LXC's cgroup memory.current |
| First start | empty image store, docker compose up -d --build until the web page answers (includes downloading ~198 MiB) |
Results
All numbers are the median of 3 runs unless it says otherwise. "Host RAM" and "host disk" are what the Proxmox host pays, measured from the host.
| VM | LXC | Difference | |
|---|---|---|---|
| Host RAM, app running, idle | 664 MiB (660, 664, 666) | 104 MiB (102, 104, 106) | LXC uses ~1/6 |
| Start: off -> web page answering | 16.4 s (15.8, 16.4, 16.6) | 6.8 s (6.7, 6.8, 6.8) | LXC 2.4x faster |
Web requests/s (wrk, 50 connections) |
5,700 (5,564, 5,700, 5,704) | 9,081 (9,009, 9,081, 9,117) | LXC +59% |
| Web latency, median | 8.94 ms | 5.28 ms | |
| Host disk used (ZFS, after the tests) | 3.16 GB | 2.27 GB | LXC 28% less |
| First start, empty image store (2 runs) | 57.6 s, 62.8 s | 70.4 s, 87.6 s | VM faster |
| Proxmox snapshot while serving (1 run) | 1.8 s, 1 of 23 web checks failed | 1.4 s, 0 of 26 failed | |
Database (pgbench) and disk (fio) |
not measured fairly | not measured fairly | see What went wrong, 6 |
Notes on the numbers:
- RAM. The VM's number is everything the guest has touched: its own kernel, its own page cache, QEMU. The host cannot take that memory back while the VM runs (we turned ballooning off). The LXC's number is only what its processes use plus its share of the host's file cache. On ZFS, the cache for the LXC's files lives in the host's ZFS cache (ARC) and is not counted against the container, so the LXC's real cost is a little higher than 104 MiB.
- Start time. Most of the VM's 16 s is booting a second kernel and a second systemd. The
qm startcommand itself returned in about 3 s. - Web speed. This surprised us: we expected the two to be within 10-15%. We did not find out why the VM is slower. One thing that differs besides virtualization: the VM runs Debian's 6.1 kernel, the LXC runs the host's 6.8 kernel.
- First start. The only test the VM won. Both downloaded the same ~198 MiB; the LXC took longer to unpack the images. Our guess (not tested): writing many small files through overlayfs onto a ZFS dataset is slower than onto ext4 inside the VM's virtual disk.
- Snapshot. The single failed web check during the VM snapshot is most likely the guest agent briefly freezing the filesystem so the snapshot is consistent. One run each, so treat it as an observation, not a rate.
How our guesses turned out:
| We expected | Result |
|---|---|
| 1. LXC uses far less RAM | Right, by more than we guessed (1/6) |
| 2. LXC starts several times faster, under 5 s | Half right: 2.4x faster, but 6.8 s, not under 5 s |
| 3. LXC uses less disk | Right (28% less) |
| 4. Web and database within 10-15% | Wrong for web (LXC +59%); database not measured |
| 5. Docker in an LXC needs nesting, and something else will be odd | Right: see What went wrong 1, plus no AppArmor inside the LXC, host-wide kernel settings refused, slower first pull |
| 6. The LXC shares the host's kernel | Right: uname -r inside the LXC is the host's 6.8.12-43-pve |
Host-wide kernel settings, the clearest difference in practice:
# In the VM
$ sudo sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144
# In the LXC
# sysctl -w vm.max_map_count=262144
sysctl: permission denied on key "vm.max_map_count"
vm.max_map_count is the setting Elasticsearch, OpenSearch and some other apps ask for. In an LXC you can only change
it on the Proxmox host, for every container at once. (Our LXC already saw 262144 because that is the host's value.)
Per-network settings such as net.core.somaxconn work in both, because each container has its own network stack.
What went wrong
- Docker in an LXC without nesting. Docker installs, the Docker service starts, then every container fails:
The host's kernel log shows AppArmor blocking it:docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "proc" to rootfs at "/proc": ... permission deniedapparmor="DENIED" operation="mount" ... profile="lxc-202_</var/lib/lxc>" ... fstype="proc". The same rule also blocked the container's ownsystemd-logind. Fix:pct set 202 --features nesting=1, then restart the container. storage 'local' does not support container directories. On our second host,pct create --rootfs local:16failed. The storage's content list must include "Containers" (rootdir). Either tick it under Datacenter -> Storage, or put the container on a storage that has it (on a default install,local-zfsorlocal-lvmdo).qm disk resizetimed out on the older host (spinning disks, busy):command '/usr/bin/qemu-img resize ...' failed: got timeout. Proxmox givesqemu-img resize10 seconds. Running it yourself worked in 1.7 s:
On ZFS the same resize took 1.4 s with no problem.qemu-img resize -f qcow2 --preallocation=metadata /var/lib/vz/images/201/vm-201-disk-0.qcow2 16G qm rescan --vmid 201 # Proxmox then updates the size it shows- Installing nftables in the cloud image stopped at a question. We had written
/etc/nftables.confbefore installing the package, so dpkg asked whether to keep it, with no terminal to answer:dpkg returned an error code (1). Fix:apt-get -o Dpkg::Options::=--force-confold install nftables. - Reloading our firewall broke Docker's networking. Our
/etc/nftables.confstarts withflush ruleset, which also deletes the rules Docker made.systemctl restart dockerputs them back. At boot the order is right (firewall first, then Docker); it only bites when you reload the firewall by hand. - Our disk and database test overloaded the host, so we threw the numbers away. The host was already busy with about 60 other VMs. During our first round the host's load average jumped from 15 to 77; the LXC's results in that round were nonsense (under 1 database transaction per second) and the VM's next database run fell from 297 to 20. Our own 30-second disk test had just pushed about 20,000 writes per second into the shared pool. We stopped and did not publish database or disk numbers. If you want to compare disk speed, do it on a host that is otherwise idle, and not on a pool other people's machines depend on.
- A VM on the older host became unreliable and we never found out why. About 40 minutes in, logins and
sudosometimes hung,systemctlandjournalctlhung, and Proxmox's shutdown button did nothing (we had to use Stop). Its log, read later from its disk, simply stops: the logging service (journald) stopped writing, and anything that talks to systemd then hung. CPU idle, no disk load, no out-of-memory kill, network fine. Before that it had two failed image downloads (connection reset by peer) that the LXC next to it never had. It did not happen again on the main host. If you see this: checkjournalctl --list-bootsand whether the last entry is much older than "now". - Smaller things.
- The Debian cloud image has automatic updates turned on (the LXC template does not). On our first VM, cloud-init installed a new kernel on first boot. We turned automatic updates off in the VM for the test window so they could not run in the middle of a measurement.
- The first Proxmox shutdown of a freshly booted cloud-image VM (no guest agent yet) timed out after 120 s; a second try later took 4 s.
- A Docker image build (
apk add) in the VM failed once with exit code 6 and worked on retry. We do not know why.
Which one should you use?
Use a VM when:
- the app needs a kernel setting or module of its own (Elasticsearch/OpenSearch, or anything else
that asks you to change
sysctlvalues that are not per-network); - you want the app walled off from the host's kernel: a kernel bug or a container escape stays inside the VM;
- you want live migration between Proxmox hosts, or you run Docker the way the vendor documents it, with no special container settings;
- you want to follow Proxmox's own advice. Their container chapter says: "If you want to run application containers, for example, Docker images, it is recommended that you run them inside a Proxmox QEMU VM. This will give you all the advantages of application containerization, while also providing the benefits that VMs offer, such as strong isolation from the host and the ability to live-migrate, which otherwise isn't possible with containers."
Use an LXC when:
- RAM is what you are short of (a small home server, many small apps). In our test the LXC cost about 1/6 of the RAM;
- the app is ordinary (a web app, a database, a reverse proxy) and you trust what you run;
- you are happy to set
nesting=1(the web UI does it for you) and to live without live migration.
What we would do: one VM for anything that faces the internet or that you did not write yourself; LXCs for small trusted apps at home where RAM matters. Whichever you pick, keep the Proxmox host itself free of Docker.