Lxc- Introduction

960 views 19 slides Nov 09, 2014
Slide 1
Slide 1 of 19
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19

About This Presentation

How to use LXC containers.


Slide Content

LXC
Introduction
Lus Eduardo
[email protected]
Federal University of Pernambuco
November 2014
Lus [email protected](UFPE) LXC November 2014 1 / 19

Summary
1
Denition
2
General
3
Implementations
Main implementations
4
Using LXC
Installation
Basic Usage
Advanced Use
Lus [email protected](UFPE) LXC November 2014 2 / 19

Denition
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 [email protected](UFPE) LXC November 2014 3 / 19

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 [email protected](UFPE) LXC November 2014 4 / 19

Implementations
Figure:
Lus [email protected](UFPE) LXC November 2014 5 / 19

Summary
1
Denition
2
General
3
Implementations
Main implementations
4
Using LXC
Installation
Basic Usage
Advanced Use
Lus [email protected](UFPE) LXC November 2014 6 / 19

Main implementations
LXC
Mostly written in C
Stable and mature codebase
Docker
Mostly written in Go
Stable and mature codebase
Similar architecture with conguration management
OpenVZ
Mostly written in C
Stable and mature codebase
Project that gave rise to several other
Lus [email protected](UFPE) LXC November 2014 7 / 19

Summary
1
Denition
2
General
3
Implementations
Main implementations
4
Using LXC
Installation
Basic Usage
Advanced Use
Lus [email protected](UFPE) LXC November 2014 8 / 19

Installation
Debian distributions
$ sudo apt-get install lxc
Lus [email protected](UFPE) LXC November 2014 9 / 19

Summary
1
Denition
2
General
3
Implementations
Main implementations
4
Using LXC
Installation
Basic Usage
Advanced Use
Lus [email protected](UFPE) LXC November 2014 10 / 19

Usage
Test installation:
Check congurations
$ sudo lxc-checkcong
Figure:
Lus [email protected](UFPE) LXC November 2014 11 / 19

Usage
Your rst container:
Run rst container
$ sudo lxc-create -t ubuntu -n ubuntulxc
Where:
-t: template
-n: name of container
Lus [email protected](UFPE) LXC November 2014 12 / 19

Usage
See information about new container:
Container information
$ sudo lxc-ls -f
Start new container:
Start new container
$ sudo lxc-start -n ubuntulxc
Lus [email protected](UFPE) LXC November 2014 13 / 19

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 [email protected](UFPE) LXC November 2014 14 / 19

Summary
1
Denition
2
General
3
Implementations
Main implementations
4
Using LXC
Installation
Basic Usage
Advanced Use
Lus [email protected](UFPE) LXC November 2014 15 / 19

Advanced Use
Containers storage: /var/lib/lxc/
Main conguration le: /var/lib/lxc/YOURCONTAINER/cong
Cgroups les: /sys/fs/cgroup/.../lxc/YOURCONTAINER/
Scripts to install some templates: /usr/share/lxc/templates
Lus [email protected](UFPE) LXC November 2014 16 / 19

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.softlimitinbytes 268435456
$ sudo lxc-cgroup -n ubuntulxc memory.limitinbytes 53687091
More cgroups here.
Lus [email protected](UFPE) LXC November 2014 17 / 19

References
LXC Ubuntu. Avaiable at:
https://help.ubuntu.com/lts/serverguide/lxc.html.
Oracle Documentation. Avaiable at:
https://docs.oracle.com/cd/E3767001/E37355/html/olcgroups.html.
Arch Linux Containers. Avaiable at:
https://wiki.archlinux.org/index.php/LinuxContainers.
Wikipedia LXC. Avaiable 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 [email protected](UFPE) LXC November 2014 18 / 19

LXC
Introduction
Lus Eduardo
[email protected]
Federal University of Pernambuco
November 2014
Lus [email protected](UFPE) LXC November 2014 19 / 19