Create LXC containers with pct and pveam
Download a container template with pveam, create an unprivileged LXC container with pct, give it a network address and get a shell inside it.
Not checked by a trusted editor yet Last edited Outdated?
A Proxmox VE container is a Linux system that shares the host kernel through LXC. Containers start in seconds and use little memory, which makes them a good fit for small Linux services. You create them from a template, a compressed root file system of a distribution.
1. Download a template
pveam (Proxmox VE Appliance Manager) lists and downloads templates. The list is refreshed daily, but you can update it by hand. Download into a storage that allows container templates, such as local.
pveam update
pveam available --section system
pveam download local <template-file>
pveam list local
Replace <template-file> with an exact name from the output of pveam available; names change with every release. After the download, pveam list local shows the full volume ID to use, in the form local:vztmpl/<template-file>. The web UI offers the same function under the storage’s CT Templates tab.
2. Create the container
pct create 200 local:vztmpl/<template-file> \
--hostname dns01 \
--memory 512 --swap 512 --cores 1 \
--rootfs local-lvm:8 \
--net0 name=eth0,bridge=vmbr0,ip=192.0.2.20/24,gw=192.0.2.1 \
--ssh-public-keys /root/.ssh/admin.pub \
--unprivileged 1 \
--onboot 1
--rootfs local-lvm:8allocates an 8 GiB root volume on thelocal-lvmstorage.--net0createseth0attached to bridgevmbr0. Useip=dhcpfor DHCP.--unprivileged 1maps root inside the container to an unprivileged user on the host. This is the default for new containers and the safer choice.--passwordprompts for a root password if you prefer that to SSH keys.
3. Start it and get a shell
pct start 200
pct enter 200 # root shell inside the container
pct console 200 # login prompt on the container console
pct exec 200 -- apt update
pct enter is the quickest way in from the host. Leave the shell with exit.
4. Change it later
pct config 200
pct set 200 --memory 1024
pct set 200 --mp0 local-lvm:20,mp=/srv/data # add a 20 GiB volume
pct push 200 ./app.conf /etc/app.conf
pct pull 200 /var/log/syslog ./ct200-syslog
Many settings, such as memory and network, can be changed while the container runs.
Things that differ from VMs
- Containers only run Linux, and they use the host’s kernel.
- Running containers cannot be live-migrated.
pct migrate 200 pve2 --restartshuts the container down, moves it and starts it again on the target node. - Some workloads, such as running Docker inside a container or certain systemd features, need extra options like
--features nesting=1. When in doubt, use a VM for those. - If a container will not start,
pct start 200 --debugprints a debug log.
Removing a container
Warning: pct destroy deletes the container and its volumes for good. Confirm the ID with pct config 200 and make sure you have a backup first.
pct config 200 | grep hostname
pct stop 200
pct destroy 200 --purge
Official documentation
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0100 Create a VM and a cloud-init template with qm Create KVM virtual machines from the command line with qm, then build a reusable cloud-init template from a cloud image and clone… Intermediate · Step by step · Linux Article Basics · VMs & containers 15 Oct 2026
- 0104 Build a Proxmox VE cluster with pvecm and live-migrate VMs Join Proxmox VE nodes into a cluster with pvecm create and pvecm add, check quorum with pvecm status, then move running VMs… Advanced · Step by step · Linux Article Clusters & high availability · VMs & containers 15 Oct 2026
- 0107 Proxmox VE command line cheat sheet: qm, pct, pvecm, pvesm and more The Proxmox VE commands you use most: qm for VMs, pct for containers, pvesm for storage, pvecm for the cluster, vzdump for… Intermediate · Cheat sheet · Linux Article Clusters & high availability · VMs & containers 15 Oct 2026
- 0108 List all Proxmox VE guests with status and locks (pvesh + jq) A Bash script that lists every VM and container in the cluster with node, status, lock, memory and uptime, using the Proxmox… Intermediate · Cheat sheet · Linux Script Shell scripting · VMs & containers 15 Oct 2026
- 0110 Fix: TASK ERROR: VM is locked (backup) A VM or container still carries a backup lock, usually after a backup was interrupted. Check that no backup is running, then… Beginner · Fixes an error · Linux Article Backup & restore · VMs & containers 15 Oct 2026
- 0111 Fix: can’t lock file ‘/var/lock/qemu-server/lock-VMID.conf’ – got timeout Another task is holding the VM's local lock file, so a new action timed out waiting for it. Find the running or… Intermediate · Fixes an error · Linux Article VMs & containers 15 Oct 2026
Repos in the wild
- proxmox/qemu-server: the Proxmox VE virtual machine manager proxmox/qemu-server Read-only GitHub mirror of qemu-server, the Proxmox VE package that manages QEMU/KVM virtual machines and provides the qm and qmrestore commands. GitHub
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Commitpedia +2,994 chars