Book Image

Containerization with LXC

Book Image

Containerization with LXC

Overview of this book

In recent years, containers have gained wide adoption by businesses running a variety of application loads. This became possible largely due to the advent of kernel namespaces and better resource management with control groups (cgroups). Linux containers (LXC) are a direct implementation of those kernel features that provide operating system level virtualization without the overhead of a hypervisor layer. This book starts by introducing the foundational concepts behind the implementation of LXC, then moves into the practical aspects of installing and configuring LXC containers. Moving on, you will explore container networking, security, and backups. You will also learn how to deploy LXC with technologies like Open Stack and Vagrant. By the end of the book, you will have a solid grasp of how LXC is implemented and how to run production applications in a highly available and scalable way.
Table of Contents (17 chapters)
Containerization with LXC
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface

Libvirt Python bindings


In Chapter 3, Command-Line Operations Using Native and Libvirt Tools, we explored an alternative way of working with LXC through the use of the libvirt userspace tools. Libvirt provides Python bindings that we can use to write applications, with the main benefit of uniformity with other virtualization technologies. It's quite convenient to write Python applications for KVM, XEN, and LXC using just one common library.

In this section, we are going to explore some of the Python methods provided by the libvirt library to create and control LXC containers.

Installing the libvirt Python development packages

Let's start by installing the required packages and starting the service.

On Ubuntu, run the following:

root@ubuntu:~# apt-get install python-libvirt debootstrap
root@ubuntu:~# service libvirt-bin start

On CentOS, the library and the service are named differently:

[root@centos ~]# yum install libvirt libvirt-python debootstrap
[root@centos ~]# service libvirtd start

Since...