Skip to Content

Creating and Managing LXC Containers

Creating and Managing LXC Containers

A vibrant collection of stacked shipping containers under a clear, blue sky. Ideal for logistic themes.

Photo by Jan van der Wolf on Pexels

Now let's get hands-on. In this lesson, we'll create an LXC container from a template, configure it, install software inside it, and learn the management commands you'll use day-to-day. By the end, you'll have a running web server container that uses a fraction of the resources a VM would need.

Step 1: Download a Container Template

Before creating a container, you need a template (a minimal root filesystem image):

  1. In the Proxmox interface, click your node name in the left panel.
  2. Click "CT" in the toolbar, then select "Templates" — or click the "Templates" button in the container storage section.
  3. You'll see a list of available templates. Select "Ubuntu 24.04 standard" (or Debian 12 if you prefer stability).
  4. Click "Download" and wait 30-60 seconds — templates are small (100-300MB).

You can also download templates from the command line:

pveam update                    # Refresh the template list
pveam available --section system  # List available system templates
pveam download local vztmpl/ubuntu-24.04-standard_24.04-1_amd64.tar.zst

Step 2: Create the Container

Click "Create CT" in the top toolbar. The wizard appears:

General Tab:

  • Node: Your server.
  • CT ID: Leave the default (auto-incremented).
  • Hostname: e.g., webserver-ct
  • Password: Set a root password for the container. You'll use this to log in initially.
  • Unprivileged container: LEAVE THIS CHECKED. Unprivileged containers are much more secure. They map the container's root user to a non-root user on the host.

Template Tab:

  • Storage: local (default).
  • Template: Select the Ubuntu template you downloaded.

Disks Tab:

  • Storage: local-lvm (default thin-provisioned storage).
  • Disk size: 8GB is plenty for a basic web server. The disk is thin-provisioned, so it only uses what's actually written.

CPU Tab:

  • Cores: 1-2. Containers are very lightweight — 1 core is often enough for simple services.

Memory Tab:

  • Memory: 512MB. This is sufficient for most web services. For databases, use 1024-2048MB.
  • Swap: 512MB (leave default).

Network Tab:

  • Name: eth0 (standard).
  • Bridge: vmbr0 (your default network bridge).
  • IPv4: DHCP (automatic) or static IP. For servers, use static: e.g., 192.168.1.50/24 with gateway 192.168.1.1.
  • IPv6: SLAAC (automatic) or leave disabled if you don't use IPv6.

DNS Tab:

  • Leave "Use host settings" checked — the container inherits the host's DNS configuration.

Confirm Tab:

  • Review your settings.
  • Check "Start after created" to boot the container immediately.
  • Click "Finish."

Step 3: Access the Container

Once created and started, you can access the container:

  1. Select the container in the left panel.
  2. Click "Console" in the center area — this opens a web-based terminal directly into the container.
  3. Login with username root and the password you set.

Or SSH into it (if you installed an SSH server):

# From the container console:
apt update && apt install openssh-server -y
# Then from your computer:
ssh root@192.168.1.50

Step 4: Install Software Inside the Container

Containers work just like regular Linux. Let's install a web server:

apt update && apt upgrade -y
apt install nginx -y
systemctl status nginx
# Test it:
curl http://localhost

You should see the "Welcome to nginx!" page. From another computer on your network, browse to http://192.168.1.50 and you'll see it too. That's a fully functional web server running in a container that uses less than 512MB of RAM.

Step 5: Managing Containers from the Command Line

# Start/stop/restart a container
pct start 101
pct stop 101
pct restart 101

# Enter a running container's shell
pct enter 101

# Push a file into the container
pct push 101 /path/to/local/file /path/inside/container

# Pull a file from the container
pct pull 101 /path/inside/container /path/to/local/file

# Take a snapshot
pct snapshot 101 pre-update-snap

# Roll back to a snapshot
pct rollback 101 pre-update-snap

# Destroy a container (be careful!)
pct destroy 101

Step 6: Backups and Snapshots

Container backups work exactly like VM backups in Proxmox:

  • Snapshots: Instant point-in-time copies. Great before making changes. Access via the container's "Snapshots" tab.
  • Backups: Full container image stored in backup storage. Schedule these in Datacenter then Backup or do them manually from the container's "Backup" tab.
  • Clone: Create a copy of a container. Use "Full Clone" for a completely independent copy, or "Linked Clone" for a space-efficient copy that shares the base image with the original.

Key Takeaways

  • Creating a container is a guided wizard — even simpler than creating a VM
  • Always use unprivileged containers for better security
  • Containers start in seconds and use a fraction of VM resources
  • Manage containers with pct commands — start, stop, enter, snapshot, and destroy
  • Backups and snapshots work identically for containers and VMs

Creating and Managing LXC Containers

A vibrant collection of stacked shipping containers under a clear, blue sky. Ideal for logistic themes.

Photo by Jan van der Wolf on Pexels

Now let's get hands-on. In this lesson, we'll create an LXC container from a template, configure it, install software inside it, and learn the management commands you'll use day-to-day. By the end, you'll have a running web server container that uses a fraction of the resources a VM would need.

Step 1: Download a Container Template

Before creating a container, you need a template (a minimal root filesystem image):

  1. In the Proxmox interface, click your node name in the left panel.
  2. Click "CT" in the toolbar, then select "Templates" — or click the "Templates" button in the container storage section.
  3. You'll see a list of available templates. Select "Ubuntu 24.04 standard" (or Debian 12 if you prefer stability).
  4. Click "Download" and wait 30-60 seconds — templates are small (100-300MB).

You can also download templates from the command line:

pveam update                    # Refresh the template list
pveam available --section system  # List available system templates
pveam download local vztmpl/ubuntu-24.04-standard_24.04-1_amd64.tar.zst

Step 2: Create the Container

Click "Create CT" in the top toolbar. The wizard appears:

General Tab:

  • Node: Your server.
  • CT ID: Leave the default (auto-incremented).
  • Hostname: e.g., webserver-ct
  • Password: Set a root password for the container. You'll use this to log in initially.
  • Unprivileged container: LEAVE THIS CHECKED. Unprivileged containers are much more secure. They map the container's root user to a non-root user on the host.

Template Tab:

  • Storage: local (default).
  • Template: Select the Ubuntu template you downloaded.

Disks Tab:

  • Storage: local-lvm (default thin-provisioned storage).
  • Disk size: 8GB is plenty for a basic web server. The disk is thin-provisioned, so it only uses what's actually written.

CPU Tab:

  • Cores: 1-2. Containers are very lightweight — 1 core is often enough for simple services.

Memory Tab:

  • Memory: 512MB. This is sufficient for most web services. For databases, use 1024-2048MB.
  • Swap: 512MB (leave default).

Network Tab:

  • Name: eth0 (standard).
  • Bridge: vmbr0 (your default network bridge).
  • IPv4: DHCP (automatic) or static IP. For servers, use static: e.g., 192.168.1.50/24 with gateway 192.168.1.1.
  • IPv6: SLAAC (automatic) or leave disabled if you don't use IPv6.

DNS Tab:

  • Leave "Use host settings" checked — the container inherits the host's DNS configuration.

Confirm Tab:

  • Review your settings.
  • Check "Start after created" to boot the container immediately.
  • Click "Finish."

Step 3: Access the Container

Once created and started, you can access the container:

  1. Select the container in the left panel.
  2. Click "Console" in the center area — this opens a web-based terminal directly into the container.
  3. Login with username root and the password you set.

Or SSH into it (if you installed an SSH server):

# From the container console:
apt update && apt install openssh-server -y
# Then from your computer:
ssh root@192.168.1.50

Step 4: Install Software Inside the Container

Containers work just like regular Linux. Let's install a web server:

apt update && apt upgrade -y
apt install nginx -y
systemctl status nginx
# Test it:
curl http://localhost

You should see the "Welcome to nginx!" page. From another computer on your network, browse to http://192.168.1.50 and you'll see it too. That's a fully functional web server running in a container that uses less than 512MB of RAM.

Step 5: Managing Containers from the Command Line

# Start/stop/restart a container
pct start 101
pct stop 101
pct restart 101

# Enter a running container's shell
pct enter 101

# Push a file into the container
pct push 101 /path/to/local/file /path/inside/container

# Pull a file from the container
pct pull 101 /path/inside/container /path/to/local/file

# Take a snapshot
pct snapshot 101 pre-update-snap

# Roll back to a snapshot
pct rollback 101 pre-update-snap

# Destroy a container (be careful!)
pct destroy 101

Step 6: Backups and Snapshots

Container backups work exactly like VM backups in Proxmox:

  • Snapshots: Instant point-in-time copies. Great before making changes. Access via the container's "Snapshots" tab.
  • Backups: Full container image stored in backup storage. Schedule these in Datacenter then Backup or do them manually from the container's "Backup" tab.
  • Clone: Create a copy of a container. Use "Full Clone" for a completely independent copy, or "Linked Clone" for a space-efficient copy that shares the base image with the original.

Key Takeaways

  • Creating a container is a guided wizard — even simpler than creating a VM
  • Always use unprivileged containers for better security
  • Containers start in seconds and use a fraction of VM resources
  • Manage containers with pct commands — start, stop, enter, snapshot, and destroy
  • Backups and snapshots work identically for containers and VMs
Rating
0 0

There are no comments for now.

to be the first to leave a comment.