LXC is an operating-system-level virtualization method for running multiple isolated Linux systems on a control host using a single Linux kernel.
Install
sudo apt install -y lxc lxc-templatescheck the LXC using the following command:
lxc-checkconfigCreate LXC Container
LXC comes with lots of ready-made templates. List them with
ls /usr/share/lxc/templates/
create your first container
sudo lxc-create --template download --name u1
lxc-create -n new-container -t ubuntuThis will interactively ask for a container root filesystem type to download – in particular the distribution, release, and architecture. To create the container non-interactively, you can specify these values on the command line:
sudo lxc-create -t download -n u1 -- --dist ubuntu --release DISTRO-SHORT-CODENAME --arch amd64
# or
sudo lxc-create -t download -n u1 -- -d ubuntu -r DISTRO-SHORT-CODENAME -a amd64List containers:
lxc-lsStart Container
lxc-start -n new-container -dtake a console of the container
lxc-console -n new-containerget the details of the running container
lxc-info -n new-containerstart and stop the container
lxc-start -n new-container
lxc-stop -n new-containerPause and Unpause the container
lxc-freeze -n new-container
lxc-unfreeze -n new-containerYou can also take a snapshot of the container
# First stop the container
lxc-stop -n new-container
# take a snapshot of the container
lxc-snapshot -n new-container
# see the location of the snapshot
lxc-snapshot -L -n new-container
# You can restore the snapshot using
lxc-snapshot -r snap0 -n new-containerto delete the container
lxc-stop -n new-container
lxc-destroy -n new-containerInstall LXC Web Panel
LXC Web Panel is a GUI management tool to manage Linux containers. You can create, start, stop, clone, delete and restart Linux container from the web browser using LXC web panel.
Install
wget https://lxc-webpanel.github.io/tools/install.sh -O - | bashOnce the installation is completed, open your web browser and type the URL http://your-server-ip:5000. You will be redirected to the LXC login page.
Now, enter the default username admin and password admin, then click on the Log In button
You can update the LXC web panel using the following command:
wget https://lxc-webpanel.github.io/tools/update.sh -O - | bash