Hello! Let’s take a closer look at Proxmox VE and its powerful feature, Linux Containers (LXC), which will make your IT life smarter. If you’re considering server virtualization, LXC is definitely a magical solution that will make your workloads much more efficient.
—.
🚀 Introduction: Proxmox VE and LXC, why do they matter?
Proxmox Virtual Environment (VE) is a powerful, open source-based server virtualization platform. Traditionally, it has been used to run a variety of OSes, primarily through its KVM-based virtual machine (VM) capabilities, but Proxmox goes a step further and fully supports a container-based virtualization technology called LXC.
So why should you care about LXC? A typical VM virtualizes and runs the entire Guest OS, which introduces a certain amount of overhead. But LXC isolates applications while sharing the kernel of the host OS, making it much lighter, faster, and more resource efficient. It’s a bit like having multiple households in an apartment building, each using their own space independently, but sharing the building’s infrastructure (water, electricity, heating, etc.) 🏢.
In this article, we’ll dive into the details of what LXCs are, how to create and manage them, and how they can benefit you in your Proxmox VE environment.
—.
1. What is an LXC? 🤔
Linux Containers (LXC) is a type of Linux container technology that provides operating system-level virtualization. It is similar to application container technologies like Docker, but LXC focuses on providing a self-contained operating system environment that is more like a “virtual machine”.
1.1. Difference between virtual machines (VMs) and containers (LXCs) 🆚
Distinction | Virtual Machine (VM) | Container (LXC) |
---|---|---|
How it works | Each guest OS runs on top of a hypervisor | Shares the kernel of the host OS and provides an isolated environment |
Resource | Independent OS booting and running is resource intensive | Shared host kernel consumes fewer resources, very lightweight |
Boot speed | Slow because it boots the entire OS | Very fast (in seconds) because it only starts processes inside the container |
Isolation Level | Full isolation, no OS type restrictions | Less isolation than VMs due to host kernel sharing, Linux only |
Uses | Diverse OS environments, high isolation needs, legacy systems | Lightweight, fast services, dev/test environments, microservices |
1.2. Key features and benefits of LXC 👍 1.
- Extreme performance: Because it shares the host kernel, it has almost none of the overhead of virtualizing the entire OS like a VM, resulting in near-native performance. 🚀
- Incredible resource efficiency: No need to install a guest OS, so you consume much less disk space, RAM, and can run much more containers on one physical server.
- Lightning-fast deployment and booting:** Containers take seconds to start, ideal for quickly deploying and testing new services or development environments.
- Easy to manage: Proxmox VE’s intuitive web interface allows you to manage LXCs almost identically to VMs.
- Portability: LXC containers can be easily migrated between Proxmox, or backed up and restored.
1.3. Disadvantages and considerations of LXC ⚠️
- Linux Only: Because LXC is based on the Linux kernel, you cannot run Windows or other Unix-like operating systems as containers. (You must use a KVM VM in this case.)
- Security Level: Because they share the host kernel, they theoretically have a lower level of security isolation than VMs; however, features such as
unprivileged container
can be used to increase security. - Kernel version dependency: Depending on the host kernel, there may be restrictions on using certain drivers or kernel modules inside the container.
—.
2. Proxmox meets LXC 🤝
Proxmox VE provides the ability to manage KVM-based virtual machines and LXC-based containers from one unified web interface. This brings tremendous convenience to IT admins. You can efficiently mix and match VMs for heavy services and LXCs for lightweight and fast web servers, databases, development environments, and more on one server.
Proxmox fully supports all the necessary features for LXCs, including template downloads, creation wizards, resource monitoring, backup/restore, snapshots, migration, and more. The best part is that you can handle LXCs as if you were handling VMs.
—.
3. Hands-on LXC creation and management in Proxmox 🛠️
Now let’s walk through how to create and manage LXC containers directly through the Proxmox VE web interface.
3.1. Download the LXC template 📥
To create an LXC container, you first need to download the template for the operating system you will be using.
- Access the Proxmox VE web interface:** Connect to
https://[Proxmox_IP]:8006
in a web browser. - Select Storage:** From the left menu, select
Datacenter
->[Storage to use]
(e.g.local
orlocal-lvm
). - Download a container template:** Click the
CT Templates
tab in the center menu, then click theTemplates
button. - Select and download the template:** Select the desired OS template (e.g.
debian-11-standard
orubuntu-22.04-standard
) and click theDownload
button.- 💡 Tip: The
-standard
version contains minimal packages, making it lighter and faster to get started.
- 💡 Tip: The
3.2. Create an LXC container 🏗️
Once the template has finished downloading, click the Create CT
button on the top right of the Proxmox web UI.
Proceed through the step-by-step wizard:.
-
General:
- Enter a name for the container (e.g.,
my-web-server-lxc
) - Password: Set the password for the
root
account. Enter it one more time for confirmation. - Unprivileged container: VERY IMPORTANT! For security reasons, we strongly recommend checking this option.** Checking this option will prevent the
root
inside the container from having the host’sroot
privileges, reducing security risks. 🚨] - Click
Next
- Enter a name for the container (e.g.,
-
Template: * Click **Template
- Storage: Select the storage where you downloaded the template.
- Template: Select the template you just downloaded (e.g.
debian-11-standard
) - Click
Next
-
Disk (Disk)
- Disk Size: Enter the amount of disk space you want to allocate to the container, in GB. (Example:
8
GB) - Click `Next
- Disk Size: Enter the amount of disk space you want to allocate to the container, in GB. (Example:
-
CPU
- Cores: Specify the number of CPU cores to allocate to the container. (For example,
1
or2
) - Click `Next
- Cores: Specify the number of CPU cores to allocate to the container. (For example,
-
Memory * Memory: Specify the number of CPU cores to allocate.
- Memory (MiB): Enter the amount of RAM to allocate, in MB. (Example:
512
MiB = 0.5 GB) - Swap (MiB): Enter the size of the swap space in MB. (Example:
512
MiB) - Click `Next
- Memory (MiB): Enter the amount of RAM to allocate, in MB. (Example:
-
Network:
- Bridge: Select
vmbr0
(default) * IPv4 / IPv6: Select `IPv4 / IPv6 (default) - IPv4 / IPv6:
- Static IP: We recommend assigning a static IP address (e.g.,
192.168.1.100/24
), where/24
is the subnet mask. - Gateway: Enter the gateway address for your network. (For example,
192.168.1.1
)
- Static IP: We recommend assigning a static IP address (e.g.,
- Click
Next
- Bridge: Select
-
**DNS
- DNS Domain: (Optional) Set the domain name.
- DNS Server: (Optional) Enter the DNS server address to use. If left blank, the host’s DNS settings will be followed.
- Click `Next
-
click `Confirm
- Review all of your settings and click the
Finish
button to complete the container creation.
- Review all of your settings and click the
3.3. LXC Container Management ⚙️
The created LXC container will appear in the left menu of the Proxmox VE web interface with a list of VMs
. By clicking on the container, various management options are available.
- Access the console ⌨️:
- Select the container and click the top
Console
tab to open a terminal window. - **Log in with the
root
account and the password you set at creation to control the inside of the container. - Example:
# After logging in as root, run the package update apt update apt upgrade -y
- Select the container and click the top
- Start/Shutdown/Reboot: Control the state of the container with the
Start
,Shutdown
, andReboot
buttons in the top menu. LXC is very fast to boot! - Adjust resources:**
-
- In the
Resources
tab, you can change the number of CPU cores, memory, disk size, etc. dynamically or after rebooting the container.
- In the
- Example: If you want to increase the number of CPU cores from 2 to 4 due to increased web server traffic, you can change it in
Resources
->CPU
of the LXC and thenrestart
it.
-
- Change network settings: You can change the IP address, gateway, etc. in the
Network
tab. - Snapshot 📸: In the
Snapshot
tab, you can save the state of your container at a specific point in time and restore it when needed. It’s a good practice to take snapshots before making important changes. - Backup/Restore 💾: In the
Backup
tab, you can use Proxmox’s built-in backup feature to back up your containers and restore them when needed. This is essential for disaster recovery planning. - Migrate ➡️: You can use the
Migrate
feature to move a running LXC to another Proxmox node (in a cluster environment). - Delete 🗑️: Containers that are no longer needed can be removed via the
Delete
button. This will erase all data, so use it carefully.
—.
4. Tips and best practices for utilizing LXC 💡
Here are some tips and best practices for using Proxmox LXC more effectively.
- Separate roles per container: It is recommended to run only one major service in one container. For example, keep your Nginx web server in one LXC, your MySQL database in another, and WordPress in yet another LXC for easier debugging and better resource management in case of issues.
- Example:
- CT ID 101:
nginx-proxy-lxc
- CT ID 102:
mysql-db-lxc
- CT ID 103:
wordpress-lxc
- CT ID 101:
- Example:
- Utilizing Templates: If you have a container with a configuration that you use frequently, you can make it a
Template
. This can save you a lot of time in the future when creating containers with the same environment. - Optimize resource allocation: Allocating too many resources is wasteful, and allocating too few will cause performance issues. Monitor the actual usage of your containers to allocate the right amount of CPU, RAM, and disk. You can see resource utilization in the
Summary
tab in Proxmox. - Security tips:
- Always create containers using the
Unprivileged container
option. - Regularly update the OS and applications inside the container to patch security vulnerabilities (
apt update && apt upgrade
) - Set up firewall rules thoroughly, opening only necessary ports.
- Always create containers using the
- Regular backups: Utilize Proxmox’s built-in backup feature to regularly backup your important LXC containers.
—.
Closing remarks ✨
Proxmox VE’s LXC feature is a great choice for those looking for a lightweight, fast, and efficient server virtualization solution. Whether you want to experience an independent OS environment without the heaviness of VMs, or need to run more services with limited hardware resources, LXC shines.
We hope this article has helped you understand and put Proxmox LXC into practice. Now go experience the magic of LXC on your own Proxmox server! If you have any questions, feel free to drop us a line. Happy computing!