LXC Containers on Fedora 21

HOWTO: Configure a LXC Linux Container on Fedora 21

First time i had encounter linux container some where in 2011 on SUSE 11, when my collage all at the time discussing about Solaris Zone. So decide to dig out some thing which look & feel like solaris zones in Linux.


Containers provide lightweight virtualization that lets you isolate processes and resources without the need to provide instruction interpretation mechanisms and other complexities of full virtualization.


1. Physical machine or a VM running Fedora 21.
2. Yum should be configured.
3. Enough System resources.
4. Update all packages to the latest versions available.

In my scenario: 

I am using MacBook Air as Physical Machine & for Virtulization using VMWare Fusion & on top of it Fedora 21 as guest OS, where i am about to play with LXC; You can see the beauty of Virtuliztaion, it always helping me to try the hell of the new technologies with minimum huddles & maximum outcome.

Screen Shot 2015-02-04 at 2.50.51 am

Install management libraries and utilities: 

Amits-MacBook-Air:~ amitvashist$ fed21
root@'s password:
Last login: Thu Jan 15 16:55:57 2015 from

[root@fedora21 ~]# yum history list 5
Failed to set locale, defaulting to C
Loaded plugins: langpacks
ID     | Command line             | Date and time    | Action(s)      | Altered
 5 | install libvirt libvirt- | 2014-12-31 10:11 | Install        |    6   
history list
[root@fedora21 ~]#

[root@fedora21 ~]#yum -y install libvirt-daemon-lxc libvirt-daemon-config-network

Launch libvirtd via systemd and ensure that it always comes up on boot. This step will also adjust firewalld for your containers and ensure that dnsmasq is serving up IP addresses via DHCP on your default NAT network.

[root@fedora21 ~]# systemctl start libvirtd.service
[root@fedora21 ~]# systemctl enable libvirtd.service
[root@fedora21 ~]# systemctl status network.service
[root@fedora21 ~]# systemctl start network.service
[root@fedora21 ~]# systemctl enable network.service

Now we ready to download / install container’s filesystem:

[root@fedora21 ~]# yum -y --installroot=/var/lib/libvirt/filesystems/fedora21 --releasever=21 --nogpg install systemd passwd yum fedora-release vim-minimal openssh-server procps-ng iproute net-tools dhclient

With the above mentioned step we have download the filesystem with the necessary packages to run a Fedora 21 container. We now need to tell libvirt about the container we’ve just created.

[root@fedora21 ~]# virt-install --connect lxc:// --name MyTestFedora21 --ram 512 --filesystem /var/lib/libvirt/filesystems/fedora21/,/

Screen Shot 2015-02-04 at 3.14.33 am

Now you container is up & running but in order to connected to the console of the container! We need to adjust some configuration files within the container to use it properly. Detach from the console with CTRL-].

Screen Shot 2015-02-04 at 3.16.10 am

So for now let’s stop the container so we can make some adjustments.

[root@fedora21 ~]# virsh -c lxc:// list
setlocale: No such file or directory
Id    Name                           State
61488 MyTestFedora21                 running
[root@fedora21 ~]#
[root@fedora21 ~]# virsh -c lxc:// shutdown MyTestFedora21
setlocale: No such file or directory
Domain MyTestFedora21 is being shutdown
[root@fedora21 ~]#

Let the container ready for production: 

  • Setup SELinux in permissive mode only for password modification, else getting:
[root@fedora21 ~]# chroot /var/lib/libvirt/filesystems/fedora21 /bin/passwd root
Changing password for user root.
New password:
Retype new password:
passwd: Authentication token manipulation error
[root@fedora21 ~]#
  • Setup the root password

Screen Shot 2015-02-04 at 3.35.06 am

  • Setup the required network configuration
[root@fedora21 ~]#cat < < EOF > /var/lib/libvirt/filesystems/fedora20/etc/sysconfig/network
[root@fedora21 ~]#cat < < EOF > /var/lib/libvirt/filesystems/fedora20/etc/sysconfig/network-scripts/ifcfg-eth0

Launching the container by keeping finger crossed :

Launching sequence : 3 2 1 – Boom!!!

[root@fedora21 ~]# virsh -c lxc:// start MyTestFedora21
setlocale: No such file or directory
Domain MyTestFedora21 started
[root@fedora21 ~]#

Screen Shot 2015-02-04 at 3.50.22 am

Now login to container with new root password: 

Screen Shot 2015-02-04 at 3.51.17 am

Testing SSH Connectivity & it seems pretty good.

Screen Shot 2015-02-04 at 4.09.17 am

Happy learning 🙂 🙂

And Please do share your comments 🙂



About Amit Vashist

Amit Vashist is someone who brings with him a treasure full of experience of over 8 years in open source technologies. When it comes to virtualization he has single handedly managed end-to-end migration projects in KVM and Xen that involved right from sizing the systems to P2V of existing physical servers. He understands what can go wrong in virtualized world and how to take care of it. He also has root level knowledge on Red Hat platforms and has commissioned & Lamp; Provides Corporate Training over Red Hat HA clusters. Now days Supporting Telecom Giant Billing & Support system, gaining experience on JBoss, Splunk, SQL, Nagios, Apache & Fuse ..etc.
This entry was posted in Linux, Uncategorized, Virtualization and tagged , , , , , , . Bookmark the permalink.

Please share your valuable suggestions/comments..!!!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s