Building Containers (LXC) & Templates
LXC containers are a lightweight alternative to full VMs. They are ideal for running Linux services with minimal overhead. However they are running as rootless, so there is little more risk to compromising hypervisor itself as it shares kernel, unlike VM. Best for internal only apps.
Note: Privileged containers run as root and have more hardware access. Unprivileged containers are more secure and recommended for most use cases.
Download Container Template
- In the web console, navigate to your node > local storage > CT Templates
- Click Templates
- Browse the template library, select a distro (e.g., Ubuntu 22.04), and click Download
Create an LXC Container
- Click Create CT in the top right corner
- General tab:
• Node: your node
• CT ID: auto-assigned
• Hostname: e.g., ubuntu-ct
• Password: set the root password for the container
• SSH public key: optionally paste your public key for key-based access - Template tab: select the downloaded template
- Disks tab:
• Storage: local-lvm
• Disk size: 8 GB is often sufficient for light services - CPU tab:
• Cores: 1–2 (containers share host CPU efficiently) - Memory tab:
• Memory: 512 MB – 1024 MB for most services
• Swap: 512 MB - Network tab:
• Bridge: vmbr0
• IPv4: DHCP or set a static IP/CIDR (e.g., 192.168.1.101/24)
• Gateway: your router IP - DNS tab: leave default or set your preferred DNS server
- Confirm and click Finish
Start the Container
- Select the container, click Start
- Click Console to open a terminal session
- Alternatively, SSH into the container using its IP address
- Update the container:
apt update && apt upgrade -y
Creating Container Template
Just like VM templates, you can convert a configured LXC container into a template for rapid reuse.
Preparing the Container
- Configure your container as desired (install packages, set configs)
- Clean up the container:
apt clean && apt autoremove -y
- Shut down the container from the web console or:
poweroff
Converting to a Template
- Right-click the container in the web console
- Select Convert to Template and confirm
Cloning a Container Template
- Right-click the template, select Clone
- Set a name and target storage for the clone
- Click Clone
- Before starting the clone, update the hostname and network settings if needed