Arunvel Arunachalam
4 min readJul 1, 2019

--

LXC 101 PART = II

This is an continuation of LXC 101, if you have not read it kindly refer https://medium.com/@csemanit2015/lxc-101-e31481801900

Recap of LXC 101 — Part I

Installed LXC in Ubuntu host machine.Created two container, one Ubuntu and one Centos.

Installed Apache2 web server in Ubuntu container and accessed web pages from the host machine

In Part-II we will cover topics such as Clone, Template & Snapshot.

  1. lxc-copy creates a clone

We are creating a clone of container arun, which we had already created.

The name given to the clone is arun4.

We can clone the container either using lxc-copy/ lxc-clone. A copy clone copies the root filesytem from the original container to the new.

2.

lxc-start = starts the container

lxc-console = attaches console of new container arun4

3.

default username = ubuntu

password = ubuntu

Now if I do a curl localhost for my new container arun4. It will have the same web-server serving the page.

Note = ubuntu@arun4 means we are in arun4 container.

4.

poweroff command is used to shutdown the container.

5.

Snapshot = Captures the entire state of the container at a particular time. When you revert to a snapshot, you return all these items to the state they were in at the time you took that snapshot.

We are taking a snapshot of container arun.

6.

When a snapshot is taken, the snapshot is saved at location

/var/lib/lxc

And a folder is created with the name of the container. The first snapshot taken is always saved with name snap0

Here we are reverting(Going back) the container to the snap0 position.

E.g Imagine you are an application developer, you have written your application in Python 2.7, now everything is working well, suddenly your manager wants you to update your application to Python 3.0

In this situation you will take a snapshot of your container running Python 2.7, and then start working on your application update in Python 3.0.

If anything goes wrong in updation, you can smoothly revert back to Python 2.7, the reason being you have taken snapshot of your container at that particular time’

7.

This is the folder ( snaps) where your container snaps are stored

8.

lxc-destroy command is the command used to destroy the container

9.

lxc-freeze freezes all the processes running inside the container The processes will be blocked until they are explicitly thawed by the lxc-unfreeze command. This command is useful for batch managers to schedule a group of processes.

Here we are freeze the container arun1

And then unfreezing it using lxc-unfreeze command.

Just for fun — Try to check of your web-server is serving pages when you freeze your container.

10.

The entire management lxc can be done via lxc-webpanel tool which will give you a dashboard through which you can create, start, stop and destroy containers

11.

Here is has installed web-panel and we can connect on

http://localhost:5000

12.

username = admin

password = admin

13.

Here you can see, container running and stopped.

14.

We have covered all basic and intermediate commands for LXC.

Next we will start with some advanced commands in LXC.

A general note = As soon I finish with LXC , we will start with Docker 101(Planning a detailed 10 part tutorial), Kubernetes 101, OpenShift 101, Ansible 101 and GOLANG 101

I hope you enjoyed part -II of LXC 101.

Please write for any doubts & feedback at csemanit2015@gmail.com

--

--