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

LXC Python bindings


LXC comes with stable C API and Python bindings for both Python 2.x and 3.x versions. Let's explore some of the functionalities that are available to us using Python 2.7.6, by writing a code that will cover most of the features provided by the userspace tools we saw in earlier chapters.

Installing the LXC Python bindings and preparing the development environment on Ubuntu and CentOS

Let's start by installing all the necessary packages that will allow us to write a functioning Python code. This includes the LXC API libraries and a Python development environment with ipython and virtualenv.

  1. To prepare an Ubuntu host, run the following commands:

    root@ubuntu:~# apt-get update && apt-get upgrade && reboot
    root@ubuntu:~# apt-get install python-pip python-dev ipython
    root@ubuntu:~# apt-get install lxc-dev=2.0.3-0ubuntu1~ubuntu14.04.1 
    liblxc1=2.0.3-0ubuntu1~ubuntu14.04.1 cgroup-lite=1.11~ubuntu14.04.2
    
    
    root@ubuntu:~# apt-get install 
    lxc-templates...