—]
π What is LXC?
Linux Containers (LXC) is an OS-level virtualization technology that runs multiple isolated user spaces (containers) on a single Linux kernel. Unlike VMs, it doesn’t require a guest OS (it shares the host OS kernel), stores less than 100MB, boots 1μ΄β±οΈ, and is incredibly efficient with performance loss π‘ VM vs LXC > – VM: Full OS emulation (CPU virtualization, independent kernel) > – LXC: process/filesystem isolation (shared kernel) β “ultra-lightweight VM”** concept
—.
π Top 5 key advantages of LXC in Proxmox
- **Performance Efficiency
- Direct access to host resources β CPU/RAM overhead β 0
- Better isolation than Docker (easier to run system services)
- **Faster Deployment
- Template-based creation β Ubuntu container creation in 3 seconds Example:
pct create 100 local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst
- Template-based creation β Ubuntu container creation in 3 seconds Example:
- **Integrated Management
- Integrated monitoring of VM/LXC in the Proxmox Web UI π
- snapshot efficiency
- Differential snapshot support β 10GB container snapshot β 0.1 seconds β‘.
- compatibility
- Full Linux environment support including systemd, SSH, cron, etc.
—.
β οΈ Cautions when using LXC
- Kernel dependencies: enforces host kernel version (e.g., no RHEL containers)
- Security: lower isolation level than VMs β mandatory use of Unprivileged Containers (Unprivileged).
- Device access: Requires additional configuration for GPU/USB passthroughs
> π How to set up an Unprivileged Container.
> Enable Unprivileged container
checkbox in Proxmox creation wizard!
—]
π οΈ Proxmox LXC creation step by step guide
1. **Prepare a template
- Repository β Select
local
β Download template (AlmaLinux, Debian, etc.)
2. Create a container
# CLI Example (Ubuntu 22.04)
pct create 101 \
local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst \
--storage local-lvm \
--cores 2 --memory 2048 \
--password mysupersecret \
--unprivileged 1
3. Network Settings.
- Bridge Mode**: Connect to
vmbr0
β Assign an independent IP. - Port Forwarding**:
iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 10.0.0.101:80
4. **Mount Settings
- Share the host directory:
# Add /etc/pve/lxc/101.conf mp0: /mnt/data,mp=/data
—]
π§ Advanced Administration Tips
**Using Snapshots
pct snapshot 101 pre-update # create
pct rollback 101 pre-update # restore
Backup Strategy.
- Incremental backup**:
vzdump --mode snapshot
- Storage replication: ZFS snapshot β remote replication
**Create a clone
Web UI right-click β “Clone” β Full clone takes 5 seconds Example!
—.
π― LXC Optimal Use Cases
- **Web server cluster
- Nginx + 10 PHP containers β 70% RAM savings compared to VMs.
- development environment
- Language-specific containers (Python/Node.js) β Prevent dependency conflicts
- Media Server
- Jellyfin + GPU pass-through:
lxc.cgroup2.devices.allow: c 226:0 rwm # /dev/dri/renderD128
- Jellyfin + GPU pass-through:
- **CI/CD Agent
- GitLab Runner Container β Can be deleted immediately after completing a task
—]
π Performance Benchmark (KVM vs LXC)
Item | KVM | LXC |
---|---|---|
CPU Score | 9800 | 9980 |
Disk IOPS | 89k | 92k |
Boot Time | 8.2 seconds | 0.3 seconds |
RAM Usage | 512MB | 28MB |
> π Test Environment: Proxmox 8.1, Xeon E5-2680v4, NVMe SSD
—.
π Conclusion: When to choose LXC?
- Recommended: Web servers, DB (MySQL), development environments, microservices
- Not Recommended: Running Windows, work requiring kernel module changes
- Core Value: > “When you need to handle dense workloads in a resource-constrained environment, LXC is a weapon!”
Proxmox’s LXC is a technology that represents the pinnacle of simplicity and power. With the right setup, you can increase your server efficiency by 300%! π.