Book Image

Containerization with LXC

By : Konstantin Ivanov
Book Image

Containerization with LXC

By: Konstantin Ivanov

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

Limiting container resource usage


In Chapter 1, Introduction to Linux Containers we saw how easy it is to limit process resources by either directly manipulating files in the cgroup hierarchy or using the userspace tools.

Similarly, LXC comes with tools that are just as straightforward and easy to use.

Let's start by setting up the available memory for a container to 512 MB:

root@ubuntu:~# lxc-cgroup -n hooks_container memory.limit_in_bytes 536870912

root@ubuntu:~#

We can verify that the new setting has been applied by directly inspecting the memory cgroup for the container:

root@ubuntu:~# cat /sys/fs/cgroup/memory/lxc/hooks_container/memory.limit_in_bytes
536870912
root@ubuntu:~#

Changing the value only requires running the same command again. Let's change the available memory to 256 MB and inspect the container by attaching to it and running the free utility:

root@ubuntu:~# lxc-cgroup -n hooks_container memory.limit_in_bytes 268435456


root@ubuntu:~# cat /sys/fs/cgroup/memory...