Lesson 3 of 9 · 23m
VMs Versus LXC: Choosing the Right Guest
The operational tradeoffs between full virtualization and containers, plus templates, cloud-init, nesting, privileges, and resource accounting.
The wrong question is whether VMs or containers are better. The right question is what failure domain, kernel dependency, and lifecycle the workload needs. Proxmox gives you both because mature infrastructure uses both.
The actual boundary
A QEMU/KVM VM has its own kernel, virtual hardware, BIOS or UEFI, disk controller, and network adapters. It can run Windows, BSD, unusual kernels, or anything needing strong isolation. The cost is memory overhead, device emulation, and slower provisioning.
An LXC container shares the host kernel. It is fast, dense, easy to snapshot, and cheap to clone. It is excellent for Linux services with ordinary user-space needs. It is the wrong tool when the workload needs kernel modules, custom sysctl behavior, or an operating system that is not Linux.
Privileged versus unprivileged containers
pct create 200 local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst --hostname dns01 --memory 1024 --cores 2 --net0 name=eth0,bridge=vmbr0,ip=192.0.2.20/24,gw=192.0.2.1 --rootfs local-zfs:8 --unprivileged 1Unprivileged containers map container root to an unprivileged host UID range. That mapping is the security feature. It also means host-level file permissions can look strange when inspected directly. Privileged containers are simpler for some legacy software but give root inside the container a much more direct relationship to host root.
Cloud-init is for VMs, not magic
qm create 101 --name app01 --memory 4096 --cores 4 --net0 virtio,bridge=vmbr0
qm importdisk 101 debian-12-genericcloud-amd64.qcow2 local-zfs
qm set 101 --scsihw virtio-scsi-single --scsi0 local-zfs:vm-101-disk-0
qm set 101 --ide2 local-zfs:cloudinit --boot order=scsi0
qm set 101 --ipconfig0 ip=192.0.2.30/24,gw=192.0.2.1 --ciuser opsCloud-init handles hostname, users, SSH keys, network configuration, and first-boot expansion for cloud images. Build one clean template per OS release. Do not clone a hand-maintained snowflake VM and then wonder which hidden setting came along.
Resource honesty
VM memory is generally reserved as allocated; containers are more elastic but still constrained by memory, CPU, and cgroup limits. Ballooning can reclaim VM memory, yet it depends on guest cooperation and complicates capacity planning. Oversubscribe CPUs carefully, memory reluctantly, and storage only with monitoring.
Field notes
- Docker inside unprivileged LXC often requires nesting and keyring options; Docker inside a VM is simpler and has a cleaner security boundary.
- Container backup consistency is usually good, but databases inside containers still need application-aware dumps or snapshots.
- Templates are infrastructure artifacts. Version them, patch them, and record how they were built.
pct enteris convenient but bypasses some normal operational discipline; prefer SSH or automation for repeatable changes.- Use qemu-guest-agent in VMs and enable it in Proxmox; clean shutdowns, IP reporting, and filesystem freeze hooks depend on it.
Was this lesson helpful?