Sunday, January 19, 2025
Google search engine
HomeUncategorisedRun Debian / Ubuntu Linux in LXC Container on Promox VE

Run Debian / Ubuntu Linux in LXC Container on Promox VE

I use Proxmox Virtualization solution to run most of my applications at home. The common way of deploying Virtual Machines on Proxmox VE is installation of full-blown OS from an ISO image – this can be Linux, Windows or BSD based systems. The setup process for this can be tedious if no automation solution is already in use. The alternative easy way to this is to use LXC container, which is lightweight and can be deployed in seconds.

Linux is a popular open-source operating system that has been adopted widely in computers, servers, and other devices. It is well known for its reliability, security, and ability to customize as required. Linux provides users with a range of tools and features that make it easy to use and flexible.

LXC or Linux Containers, on the other end, is a lightweight virtualization technology that enables you to create and run multiple isolated virtual environments on a single Linux system. Each container in LXC will have its own network, file system, and processes. This makes it easy to run and manage applications.

In this tutorial we shall capture the process that you’ll follow when installing and configuring Debian based Linux container. You’ll need a working Proxmox VE to use this installation on your base system. Promox VE already have LXC installed and working.

Run Debian / Ubuntu LXC Container on Promox VE

Login to your Promox VE.

ssh root@Promox_ServerIP

Check version of LXC to validate it’s installed.

# dpkg -l lxc-pve
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  lxc-pve        5.0.0-3      amd64        Linux containers userspace tools

There are set of tools called Proxmox Helper Scripts which allows you to create a Linux container or virtual machine in an interactive manner, with options for both basic and advanced configurations.

Let’s download script that simplifies installation of Debian Linux container on Promox virtualization environment.

### Debian ###
wget https://github.com/tteck/Proxmox/raw/main/ct/debian.sh

### Ubuntu ###
wget https://github.com/tteck/Proxmox/raw/main/ct/ubuntu.sh

Make the script executable using chmod command

### Debian ###
chmod +x debian.sh

### Ubuntu ###
chmod +x ubuntu.sh

Execute the script to begin Debian LXC container installation on Proxmox.

### Debian ###
./debian.sh

### Ubuntu ###
./ubuntu.sh

In the first prompt accept creation of Debian LXC.

create debian lxc container 01

For easy setup you can choose Default Settings

create debian lxc container 02

For customized installation – hostname, root password, IP address and other settings, choose “Advanced”

create debian lxc container 03

Choose the type of container. For any other use “Unprivileged” is okay, unless you know why you’re choosing Privileged.

create debian lxc container 04

Set root password. This is required if SSH access is enabled for the container.

create debian lxc container 05

Set container ID. You can just ignore and leave auto-generated number.

create debian lxc container 06

Next set the hostname of the container. Once done hit “Ok

create debian lxc container 07

The default disk size might be too small for your application. Set desired storage capacity in the next section.

create debian lxc container 08

Also set CPU cores to be allocated to your container.

create debian lxc container 09

RAM is set in MB. In my example the container will have 2GB memory.

create debian lxc container 10

Set bridge name for networking. You can check available bridges in your Proxmox server using brctl command.

$ brctl show
bridge name	bridge id		STP enabled	interfaces
fwbr100i0		8000.72b1156fbaaf	no		fwln100i0
							tap100i0
fwbr103i0		8000.e6f2392dab97	no		fwln103i0
							tap103i0
fwbr115i0		8000.ae948f1263b5	no		fwln115i0
							tap115i0
vmbr0		8000.5a0e9a8256fa	no		fwpr100p0
							fwpr103p0
							fwpr115p0
							veth117i0

I’ll use vmbr0 – default Proxmox bridge if you didn’t customize.

create debian lxc container 11

On IP address you can choose DHCP or set static IP address.

create debian lxc container 12

If using static IP address, combine IP and subnet. E.g 192.168.20.40/24. Next provide the default gateway, e.g 192.168.20.1

create debian lxc container 13

You have the option of using or disabling IPv6. For me I don’t need it enabled in this container.

create debian lxc container 14

Depending on the use case you can set MTU size.

create debian lxc container 15

Optionally set DNS search domain. This is more practical with internal DNS server use.

create debian lxc container 16

DNS server IP address can be specified. For DHCP leave it blank.

create debian lxc container 17

MAC address setting is also available in advanced configuration option.

create debian lxc container 18

Set or ignore VLAN if not using it in your network.

create debian lxc container 19

Choose to enable or disable root access via SSH.

create debian lxc container 20

Enable or disable verbose mode.

create debian lxc container 21

When ready to create the container hit “Yes” key.

create debian lxc container 22

If the creation is successful you should see a message similar to one below.

create debian lxc container 24

You can also display more information about created container using lxc-info command.

$ lxc-info 117
Name:           117
State:          RUNNING
PID:            1053938
IP:             192.168.207.128
Link:           veth117i0
 TX bytes:      187.60 KiB
 RX bytes:      19.79 MiB
 Total bytes:   19.97 MiB

We can test ping

$ ping -c 2 192.168.207.128
PING 192.168.207.128 (192.168.207.128) 56(84) bytes of data.
64 bytes from 192.168.207.128: icmp_seq=1 ttl=64 time=0.041 ms
64 bytes from 192.168.207.128: icmp_seq=2 ttl=64 time=0.039 ms

--- 192.168.207.128 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.039/0.040/0.041/0.001 ms

SSH as root user should be possible if it was enabled.

$ ssh [email protected]
The authenticity of host '192.168.207.128 (192.168.207.128)' can't be established.
ECDSA key fingerprint is SHA256:pagZQOlpXT3MUMaCXKGw/gn6ivW4StfZCVsxP3L63+0.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.207.128' (ECDSA) to the list of known hosts.
[email protected]'s password:
Debian LXC provided by https://tteck.github.io/Proxmox/

root@debian:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@debian:~# exit
logout

For console access use:

root@pve07 ~ # lxc-console 117

Connected to tty 1
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself

Debian GNU/Linux 11 debian tty1

debian login: root
Password:
Debian LXC provided by https://tteck.github.io/Proxmox/

Last login: Fri Mar 31 18:52:44 EAT 2023 from 192.168.207.1 on pts/3
root@debian:~#

Console control:

Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself

In our future article we shall cover management of LXC containers in Proxmox using CLI / UI interface.

Conclusion

In summary, Linux and LXC are powerful tools for both system administrators and developers who need to create, manage, and deploy applications in a faster, efficient and efficient way. The tools free and open-source, making them accessible to anyone who wants to use them. With Proxmox VE already deployed in your infrastructure, you can take advantage of its capabilities and available resources in running your LXC containers.

See more content on Proxmox available in our website.

RELATED ARTICLES

Most Popular

Recent Comments