The Short Answer
LXC runs system containers: a whole Linux distribution with an init system, several services, users, and often an SSH server, sharing the host's kernel. You treat it like a small virtual machine and update it in place.
Docker runs application containers: one main process built from an image. You do not log in and upgrade it; you build or pull a new image and replace the container. Both rely on kernel namespaces and cgroups, explained in what a container is.
Side by Side
| LXC | Docker | |
|---|---|---|
| Runs | A full distribution | One application |
| Inside | systemd, cron, SSH | The app process |
| Images | Distribution images | Layered app images |
| Updates | apt or dnf inside | Replace the image |
| Data | In its root file system | In volumes |
| Networking | Own IP on a bridge | Published ports |
| Lifetime | Long-lived | Disposable |
Images
An LXC image is a root file system of a distribution: Debian, Ubuntu, AlmaLinux, and so on. After it starts, it changes like any server. A Docker image is built in layers from a Dockerfile and stays read-only; the container adds a thin writable layer on top that disappears when the container is removed. Building such an image is covered in Dockerfile.
Where Data Lives
In an LXC container, data sits in the container's own file system and survives restarts and updates, as on a virtual machine. Back it up like a server. In Docker, anything that must survive goes into a volume or a bind mount, because the container itself is meant to be thrown away; see Docker volumes vs bind mounts.
Networking
A system container usually gets its own IP address on a bridge and behaves like another machine on the network. Docker puts containers on internal networks and publishes chosen ports on the host with -p; the containers talk to each other by service name.
The Tools Around Each
- LXC: the low-level
lxc-*tools, and the managers built on them: LXD and Incus, and the container support in Proxmox VE. - Docker: Docker Engine with the
dockercommand, Compose for multi-container applications, registries for sharing images, and Kubernetes when containers spread over many hosts. See what Docker is.
Docker Inside an LXC Container
It works and is common, but it has caveats:
- Nesting: the container needs nesting enabled (in Proxmox VE the
nestingfeature, often withkeyctlfor unprivileged containers). - Storage drivers: Docker's overlay storage on top of some host file systems can be slow or fail; check which driver
docker inforeports. - Security profiles: AppArmor and similar rules on the host can block things Docker does inside, and loosening them weakens isolation.
- Upgrades: a host or kernel update can break the setup in ways a virtual machine would not notice.
The Proxmox VE documentation calls nesting containers inside a virtual machine the recommended practice when you need maximum isolation and live migration. For anything important, run Docker in a virtual machine.
Which to Use for What
- Choose LXC for many small, long-lived Linux servers on one host: a DNS resolver, a mail relay, a test machine per developer, or a service you manage with your usual tools.
- Choose Docker for applications that ship as images, need the same environment in development and production, or are updated by replacing the image.
- Use both when it helps: a virtual machine or system container per project, with Docker running the applications inside it.