1. LXC
Introduction
Lus Eduardo
lets@cin.ufpe.br
Federal University of Pernambuco
November 2014
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 1 / 19
5. nition
Linux Containers (LXC for LinuX Containers) are lightweight virtual
machines (VMs) which are realized using features provided by a
modern Linux kernel { VMs without the hypervisor.
Operational system-level virtualization method for running multiples
and isolated systems (containers) on a single host.
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 3 / 19
6. General
Lightweight process virtualization is not new
Chroot
Solaris Zones
BSD jails
AIX WPARs (Workload Partitions)
Linux-based containers projects
Why now?
Kernel Support +3.8(Febuary 2013)
Namespaces
Cgroups
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 4 / 19
7. Implementations
Figure: Several ways to use container. Source:Wikipedia
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 5 / 19
9. nition
2 General
3 Implementations
Main implementations
4 Using LXC
Installation
Basic Usage
Advanced Use
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 6 / 19
10. Main implementations
LXC
Mostly written in C
Stable and mature codebase
Docker
Mostly written in Go
Stable and mature codebase
Similar architecture with con
11. guration management
OpenVZ
Mostly written in C
Stable and mature codebase
Project that gave rise to several other
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 7 / 19
23. rst container
$ sudo lxc-create -t ubuntu -n ubuntulxc
Where:
-t : template
-n : name of container
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 12 / 19
24. Usage
See information about new container:
Container information
$ sudo lxc-ls -f
Start new container:
Start new container
$ sudo lxc-start -n ubuntulxc
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 13 / 19
25. Usage
Stop a container
$ sudo lxc-stop -n ubuntulxc
Destroy a container
$ sudo lxc-destroy -n ubuntulxc
Clone a container
$ sudo lxc-clone -o ubuntulxc -n ubuntulxc2
Execute a temporary container
$ sudo lxc-execute -n guest { sleep 100
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 14 / 19
33. Advanced Use
Controlling Container Resources
CPU information
$ sudo lxc-cgroup -n ubuntulxc cpuset.cpus
CPU time and block I/O access
$ sudo lxc-cgroup -n ubuntulxc cpu.shares 256
$ sudo lxc-cgroup -n ubuntulxc blkio.weight 500
Dynamic Memory Allocation
$ sudo lxc-cgroup -n ubuntulxc memory.soft limit in bytes 268435456
$ sudo lxc-cgroup -n ubuntulxc memory.limit in bytes 53687091
More cgroups here.
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 17 / 19
34. References
LXC Ubuntu. Available at:
https://help.ubuntu.com/lts/serverguide/lxc.html.
Oracle Documentation. Available at:
https://docs.oracle.com/cd/E37670 01/E37355/html/ol cgroups.html.
Arch Linux Containers. Available at:
https://wiki.archlinux.org/index.php/Linux Containers.
Wikipedia LXC. Available at: http://en.wikipedia.org/wiki/LXC.
Rathore, Muhammad Siraj, Markus Hidell, and Peter Sjodin. KVM
vs. LXC: comparing performance and isolation of hardware-assisted
virtual routers. American Journal of Networks and Communications
2.4 (2013): 88-96.
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 18 / 19
35. LXC
Introduction
Lus Eduardo
lets@cin.ufpe.br
Federal University of Pernambuco
November 2014
Lus Eduardo lets@cin.ufpe.br (UFPE) LXC November 2014 19 / 19