Managing LXC in Proxmox Virtual Environment (PVE)
Managing LXC in Proxmox Virtual Environment (PVE)
Creating an LXC
Now that we have a template image, we can create a new LXC.
pct create 403 volume01:vztmpl/ubuntu-22.04-
standard_22.04-1_amd64.tar.zst \
--storage volume01 --rootfs volume=volume01:16 \
--ostype ubuntu --arch amd64 --password P@ssw0rd --
unprivileged 1 \
--cores 2 --memory 1024 --swap 0 \
--hostname lxc-ubuntu \
--net0
name=eth0,bridge=vmbr0,ip=dhcp,firewall=1,type=veth \
--start true
--net0 the
name=eth0,bridge=vmbr0,ip=dhcp,firewall=1,type=veth interface
name set to
eth0 and
bridge to
vmbr0 from
the host,
enable
firewall and
the network
type value
is: veth.
about veth
This type of network interface allows the LXC (container) or virtual
machine to communicate with other devices on the network as if it were
a physical device on the network. The veth interface also allows for
network isolation between different LXC or virtual machines running on
the same host system.
Launch a shell for the LXC
Enter the container:
pct enter 403
Create user:
useradd -m user -s /bin/bash
Switch to user:
su – user
Cleaning up
Stop the LXC
pct stop 401
Destroying an LXC
To remove an LXC from the system, use the following command:
pct destroy 401 –purge
This command destroys the LXC with ID 401 and removes its
configuration files from the system.
Removing a Template Image
If you want to remove a template image from the storage pool, use the
following command:
pveam remove volume01:vztmpl/vztmpl/ubuntu-22.04-
standard_22.04-1_amd64.tar.zst
Conclusion:
We covered the basics of managing LXC in Proxmox Virtual
Environment (PVE).
Looked at how to download a template image, create an LXC, and
configure it with various options. We also saw how to remove an LXC
from the system.
PVE offers many more commands and options for managing LXCs, and
we encourage you to explore them further to get the most out of this
powerful virtualization platform.