Introduction Linux Container

LXC (Linux Containers) is an operating system–level virtualization method for running multiple isolated Linux systems (containers) on a single control host.

The LXC commonly known as “operating system-level virtualization” or “OS Virtual Environments” containers differ from hypervisor level virtualization. The main difference is that the container model eliminates the hypervisor layer, redundant OS kernels, binaries, and libraries needed to typically run workloads in a VM.

Installing LXC in Fedora 24

Install Required Packages:

  • Package Name and Usage
  • LXC : Main Linux Container
  • debootstrap: Is necessary in order to build Debian-based containers
  • libvirt: will provide basic networking management, such us bridge, NAT and DHCP.
  • lxc-templates : Template scripts to create container of ubuntu, oracle Linux etc…

List of templates:


#dnf install lxc lxc-templates lxc-extra debootstrap libvirt

Start “libvirtd” service:

#systemctl list-unit-files | grep libvirtd

Configure network bridge:
Edit the file /etc/lxc/default.conf and change the parameter ‘’ from ‘lxcbr0’ to ‘virbr0’:

[root@gcpadman-laptop ~]# cat /etc/lxc/default.conf = veth = virbr0 (By default it will be = up = 00:16:3e:xx:xx:xx

Creating container

lxc-create -n container_name -t container_template <Release can be specifed>

lxc-create -n guru -t ubuntu

Note: It will download all the required packages and container will be ready in few minutes …go and get some coffee for yourself :)

Container Administration

  • Listing all container 
    lxc-ls -f
  • Stopping Container 
    lxc-stop -n <container name>
  • Connecting to container console
    lxc-console -n <Container Name>

Note: Use “Ctrl + a” followed by “q” to exit console

  • Query information about a container
    lxc-info -n <Container Name>
  • Stopping Container 
  • Cloning Container
    lxc-copy -n <Source Container Name> -N <Clone Name>
  • Destroy a Linux Container 
    lxc-destroy -n <Container Name> -s <Destroy including snapshots> -f <Force>

We have learnt basics of Linux Container, but as a administrator we should understand about container networking, container resource management and configuration files related to container

  1. How networking works in Container?

In our above example I have updated /etc/lxc/default.conf and updated bridge as below;

Let us analyze the bridge virbr0:

Let us analyze this further ….

Container configuration is in the directory respective to that container …

Here we have defined network type as veth. Here are the list of network type supported by LXC:

  • lo — loopback interfaces (more on this later)
  • eth0 — default network interface created by Vagrant
  • eth1 — private network interface which Vagrant created as instructed by our Vagrantfile configuration :private_network
  • eth2 — public network interface which Vagrant created as instructed by our Vagrantfile configuration :public_network
  • lxcbr0 — network bridge which was created automatically when the lxc tools have been installed

Packets are forwarded via iptables;

Like what you read? Give Guruprasad a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.