Linux Containers (LXC)

2 Mins read

LXC (Linux Containers) are a lightweight alternative to fully virtualized machines (VMs). They use the kernel of the host system that they run on, instead of emulating a full operating system (OS). This means that containers can access resources on the host system directly.

Refer to this official documentation

Proxmox VE provides a streamlined interface for creating and managing LXC containers, making it a user-friendly option even for those new to containers or virtualization. With just a few clicks, lightweight and efficient Linux environments can be deployed, ideal for homelabs and production workloads alike.

However, documenting a few commands to make this happen from the command line

Container Images

Container images, sometimes also referred to as “templates” or “appliances”, are tar archives which contain everything to run a container. Proxmox VE itself provides a variety of basic templates for the most common Linux distributions.

pveam: Proxmox VE Appliance Manager To see a list of available templates for LXC creation.

pveam available 

To narrow down this extensive list, specify the section of interest — for example, basic system images — to list only relevant system images.

pveam available --section system
Template
Available Templates

Download the template (image) to create a container of the template.

pveam download local ubuntu-24.04-standard_20240413_amd64.tar.xz
pveam list local # Displays all the downloaded templates
pveam remove local:vztmpl/ubuntu-24.04-standard_20240413_amd64.tar.xz
# Removes the downloaded template.

Proxmox VE web interface GUI can also be used to download, list and delete container templates

Create the Container

Create the container from the template downloaded earlier.

sudo pct create 901 local:vztmpl/local ubuntu-24.04-standard_20240413_amd64.tar.xz \
--cores 2 --features nesting=1 --memory 4096 \
--net0 name=eth0,bridge=vmbr0,firewall=0,ip=dhcp,hwaddr=bc:24:11:3e:41:6d \
--hostname "firstlxc" --rootfs local-lvm:32 --unprivileged 0 \
--ssh-public-keys /home/sathish/.ssh/id_mac.pub --ostype ubuntu --start 1  

Start the container and access the console

pct start 901
pct console 901
   #or
pct enter 901

pct stop 901
pct destroy 901

More commands documeted for easy reference.