SlideShare a Scribd company logo
LibCT
One Lib to Rule Them All
LibCT
One Lib to Rule Them All
Andrey Vagin
Odin, Software Engineer
ContainerCon, 2015
AgendaAgenda
• History
• Namespaces and CGroups
• LibCT
• And Libcontainer
• Current state and future plans
2
History of Linux ContainersHistory of Linux Containers
• 2002 Virtuozzo
• 2005 OpenVZ
• Linux-VServer
• 2006 Namespaces and Cgroups
• 2008 LXC (Linux Containers)
• 2010 Application Containers ...
3
History of Application ContainersHistory of Application Containers
• Systemd-nspawn
– Spawn a namespace container for debugging,
testing and building
• Docker
– LXC
– Libcontainer
• Rocket
– systemd-nspawn
4
NamespacesNamespaces
●
Mount (2.4.19 2002)
– Mount points
●
Network
– Network devices, stacks, ports, etc.
●
PID
– processes
●
IPC
– System V IPC, POSIX message queues
●
UTS
– Hostname and NIS domain name
●
User (3.8 - 2013)
– security-related identi<ers and attributes
Other features of namespacesOther features of namespaces
●
User namespaces allow to use
namespace for unprivileged users
●
Namespaces can be created once and
used many times
●
Fast entering into existing namespaces
●
Ability to isolate tasks in context of one
user
6
Usage scenariosUsage scenarios
●
Mount namespace
– to construct a new root which contains only accessible paths
(security)
– Multitenancy
●
Network namespace
– to grant full access to network devices (Network Function
Virtualization, Virtual Private Networks, etc)
– to build complex network topology
– to use iptables, tra>c shaping, etc
●
PID namespaces
– to isolate independent group of processes (security)
Control GroupsControl Groups
●
Cpu,cpuset,cpuacct
●
Memory, hugetlb
●
Blkio
●
Devices
●
net_cls, net_prio
●
Freezer
●
perf_event
The LibCT libraryThe LibCT library
●
Allows to build containerized applications
– con<gure namespaces and cgroups
– unprivileged containers
●
In C and binding for other languages
●
Cross-platform
Reasons for creating LibCTReasons for creating LibCT
●
Complexity of low-level API
●
Support of all kinds of containers
– Linux Containers
– OpenVZ
– Solaris Zones
– BSD jails
●
Hide low-level API changes
10
Libcontainer and LibCTLibcontainer and LibCT
●
In Go / In C
●
Both support back-ends
●
Only Go / binding for other languages
●
Easy for developing / works faster
●
No fork() / …
Libcontainer → runc
LibCT APILibCT API
12
Session
- create()
- load()
Container
- namespaces
- cgroups
Process
- kill(), wait()
ProcessDesc
- Uid, Git, Groups
ExampleExample
s = libct_session_open_local();
/* configure container */
ct = libct_container_create(s, "test");
libct_container_set_nsmask(ct,
CLONE_NEWPID | CLONE_NEWUSER | CLONE_NEWNS));
libct_userns_add_uid_map(ct, 0, getuid(), 1);
libct_userns_add_gid_map(ct, 0, getgid(), 1);
libct_fs_add_mount(ct, "tmpfs", "/tmp", 0, "tmpfs", NULL))
/* configure process descriptor */
p = libct_process_desc_create(s);
libct_process_desc_set_caps(p, 0, CAPS_ALL);
/* Executing process*/
pr = libct_container_spawn_cb(ct, p, set_ct_alive, ct_alive);
libct_process_wait(pr, &status);
libct_container_destroy(ct);
libct_session_close(s);
13
Future plansFuture plans
●
Integration with applications
●
Noti<cations
●
Task-less containers
●
Checkpoint/Restore (CRIU)
Thank You!
Andrey Vagin <avagin@openvz.org>
https://github.com/avagin/libct
Andrey Vagin <avagin@openvz.org>
https://github.com/avagin/libct

More Related Content

PDF
LibCT и контейнеры на уровне приложений -- Александр Бурлука
ODP
Moscow virtualization meetup 2014: CRIU 1.0 What is next?
PDF
Libcontainer: joining forces under one roof
PPTX
Cassandra Summit 2014: Drivers: Let Our Powers Combine!
PDF
OpenNebulaConf2018 - OpenNebula and LXD Containers - Rubén S. Montero - OpenN...
PDF
Docker. General overview
PDF
OpenNebula LXD Container Support overview
PDF
Cncf meetup-rook
LibCT и контейнеры на уровне приложений -- Александр Бурлука
Moscow virtualization meetup 2014: CRIU 1.0 What is next?
Libcontainer: joining forces under one roof
Cassandra Summit 2014: Drivers: Let Our Powers Combine!
OpenNebulaConf2018 - OpenNebula and LXD Containers - Rubén S. Montero - OpenN...
Docker. General overview
OpenNebula LXD Container Support overview
Cncf meetup-rook

What's hot (14)

PDF
Cncf meetup-rook
PDF
Scaling Docker Registry
ODP
Not so brief history of Linux Containers
PDF
Autentia OS - 20180210 - Docker y las películas de chinos
ODP
What's missing from upstream kernel containers?
ODP
20160401 Gluster-roadmap
PDF
How Docker didn't invent containers (Docker Meetup Brno #1)
PPTX
Comparison of existing cni plugins for kubernetes
PPTX
Notary - container signing
PDF
CRuby Committers Who's Who in 2013
PDF
Docker Introduction - DevOps Montreal Meetup
PPTX
PDF
Kubernetes from scratch at veepee sysadmins days 2019
PPTX
Kubernetes CRI containerd integration by Lantao Liu (Google)
Cncf meetup-rook
Scaling Docker Registry
Not so brief history of Linux Containers
Autentia OS - 20180210 - Docker y las películas de chinos
What's missing from upstream kernel containers?
20160401 Gluster-roadmap
How Docker didn't invent containers (Docker Meetup Brno #1)
Comparison of existing cni plugins for kubernetes
Notary - container signing
CRuby Committers Who's Who in 2013
Docker Introduction - DevOps Montreal Meetup
Kubernetes from scratch at veepee sysadmins days 2019
Kubernetes CRI containerd integration by Lantao Liu (Google)
Ad

Similar to LibCT: one lib to rule them all -- Andrey Vagin (20)

PPTX
Cgroups, namespaces and beyond: what are containers made from?
PDF
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
PDF
Containers and Namespaces in the Linux Kernel
PDF
Anatomy of a Container: Namespaces, cgroups & Some Filesystem Magic - LinuxCon
PDF
Namespaces and cgroups - the basis of Linux containers
PDF
The building blocks of docker.
PDF
Linux Container Technology 101
PDF
Linux containers-namespaces(Dec 2014)
PPTX
Linux container, namespaces & CGroup.
PPTX
Introduction to containers
PDF
dotCloud (now Docker) Paas under the_hood
PPTX
Realizing Linux Containers (LXC)
PDF
Docker containers : introduction
PPTX
Lxc – next gen virtualization for cloud intro (cloudexpo)
PPTX
Linux Container Brief for IEEE WG P2302
PDF
Scale11x lxc talk
PDF
Libcontainer: joining forces under one roof
PDF
Libcontainer: joining forces under one roof
PDF
Lightweight Virtualization: LXC containers & AUFS
PDF
GDG Cloud Iasi - Docker For The Busy Developer.pdf
Cgroups, namespaces and beyond: what are containers made from?
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
Containers and Namespaces in the Linux Kernel
Anatomy of a Container: Namespaces, cgroups & Some Filesystem Magic - LinuxCon
Namespaces and cgroups - the basis of Linux containers
The building blocks of docker.
Linux Container Technology 101
Linux containers-namespaces(Dec 2014)
Linux container, namespaces & CGroup.
Introduction to containers
dotCloud (now Docker) Paas under the_hood
Realizing Linux Containers (LXC)
Docker containers : introduction
Lxc – next gen virtualization for cloud intro (cloudexpo)
Linux Container Brief for IEEE WG P2302
Scale11x lxc talk
Libcontainer: joining forces under one roof
Libcontainer: joining forces under one roof
Lightweight Virtualization: LXC containers & AUFS
GDG Cloud Iasi - Docker For The Busy Developer.pdf
Ad

More from OpenVZ (20)

PDF
PFcache - LinuxCon 2015
ODP
Speeding up ps and top
PDF
Live migration: pros, cons and gotchas -- Pavel Emelyanov
PDF
Live migrating a container: pros, cons and gotchas -- Pavel Emelyanov
PDF
CRIU: time and space travel for Linux containers -- Kir Kolyshkin
PDF
Тестирование ПО, основанного на сторонних компонентах - Денис Силаков, SECR 2015
ODP
Живая миграция: плюсы, минусы и подводные камни - Павел Емельянов
PDF
What's missing from upstream kernel containers? - Sergey Bronnikov
PDF
Проблема фрагментации виртуальных дисков и способы её решения -- Дмитрий Монахов
PDF
Развёртывание приложений Docker в контейнерах Virtuozzo -- Павел Тихомиров
PDF
CRIU: ускорение запуска PHP в CloudLinux OS -- Руслан Купреев
PDF
Управление памятью контейнеров в проекте OpenVZ -- Владимир Давыдов
PDF
Живая миграция контейнеров: плюсы, минусы, подводные камни -- Павел Емельянов
ODP
Denser containers with PF cache - Pavel Emelyanov
ODP
CGroups kernel memory controller -- Pavel Emelyanov
ODP
What's missing from upstream kernel containers? - Kir Kolyshkin, Sergey Bronn...
ODP
Not so brief history of Linux Containers - Kir Kolyshkin
ODP
Openvz booth
PDF
Управление ресурсами в Linux и OpenVZ
PDF
Containers in a file
PFcache - LinuxCon 2015
Speeding up ps and top
Live migration: pros, cons and gotchas -- Pavel Emelyanov
Live migrating a container: pros, cons and gotchas -- Pavel Emelyanov
CRIU: time and space travel for Linux containers -- Kir Kolyshkin
Тестирование ПО, основанного на сторонних компонентах - Денис Силаков, SECR 2015
Живая миграция: плюсы, минусы и подводные камни - Павел Емельянов
What's missing from upstream kernel containers? - Sergey Bronnikov
Проблема фрагментации виртуальных дисков и способы её решения -- Дмитрий Монахов
Развёртывание приложений Docker в контейнерах Virtuozzo -- Павел Тихомиров
CRIU: ускорение запуска PHP в CloudLinux OS -- Руслан Купреев
Управление памятью контейнеров в проекте OpenVZ -- Владимир Давыдов
Живая миграция контейнеров: плюсы, минусы, подводные камни -- Павел Емельянов
Denser containers with PF cache - Pavel Emelyanov
CGroups kernel memory controller -- Pavel Emelyanov
What's missing from upstream kernel containers? - Kir Kolyshkin, Sergey Bronn...
Not so brief history of Linux Containers - Kir Kolyshkin
Openvz booth
Управление ресурсами в Linux и OpenVZ
Containers in a file

Recently uploaded (20)

PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Digital Strategies for Manufacturing Companies
PDF
top salesforce developer skills in 2025.pdf
PDF
System and Network Administration Chapter 2
PPTX
ISO 45001 Occupational Health and Safety Management System
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Nekopoi APK 2025 free lastest update
PDF
medical staffing services at VALiNTRY
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
Which alternative to Crystal Reports is best for small or large businesses.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Digital Strategies for Manufacturing Companies
top salesforce developer skills in 2025.pdf
System and Network Administration Chapter 2
ISO 45001 Occupational Health and Safety Management System
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Understanding Forklifts - TECH EHS Solution
Online Work Permit System for Fast Permit Processing
Nekopoi APK 2025 free lastest update
medical staffing services at VALiNTRY
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Operating system designcfffgfgggggggvggggggggg
Softaken Excel to vCard Converter Software.pdf
How to Migrate SBCGlobal Email to Yahoo Easily

LibCT: one lib to rule them all -- Andrey Vagin

  • 1. LibCT One Lib to Rule Them All LibCT One Lib to Rule Them All Andrey Vagin Odin, Software Engineer ContainerCon, 2015
  • 2. AgendaAgenda • History • Namespaces and CGroups • LibCT • And Libcontainer • Current state and future plans 2
  • 3. History of Linux ContainersHistory of Linux Containers • 2002 Virtuozzo • 2005 OpenVZ • Linux-VServer • 2006 Namespaces and Cgroups • 2008 LXC (Linux Containers) • 2010 Application Containers ... 3
  • 4. History of Application ContainersHistory of Application Containers • Systemd-nspawn – Spawn a namespace container for debugging, testing and building • Docker – LXC – Libcontainer • Rocket – systemd-nspawn 4
  • 5. NamespacesNamespaces ● Mount (2.4.19 2002) – Mount points ● Network – Network devices, stacks, ports, etc. ● PID – processes ● IPC – System V IPC, POSIX message queues ● UTS – Hostname and NIS domain name ● User (3.8 - 2013) – security-related identi<ers and attributes
  • 6. Other features of namespacesOther features of namespaces ● User namespaces allow to use namespace for unprivileged users ● Namespaces can be created once and used many times ● Fast entering into existing namespaces ● Ability to isolate tasks in context of one user 6
  • 7. Usage scenariosUsage scenarios ● Mount namespace – to construct a new root which contains only accessible paths (security) – Multitenancy ● Network namespace – to grant full access to network devices (Network Function Virtualization, Virtual Private Networks, etc) – to build complex network topology – to use iptables, tra>c shaping, etc ● PID namespaces – to isolate independent group of processes (security)
  • 8. Control GroupsControl Groups ● Cpu,cpuset,cpuacct ● Memory, hugetlb ● Blkio ● Devices ● net_cls, net_prio ● Freezer ● perf_event
  • 9. The LibCT libraryThe LibCT library ● Allows to build containerized applications – con<gure namespaces and cgroups – unprivileged containers ● In C and binding for other languages ● Cross-platform
  • 10. Reasons for creating LibCTReasons for creating LibCT ● Complexity of low-level API ● Support of all kinds of containers – Linux Containers – OpenVZ – Solaris Zones – BSD jails ● Hide low-level API changes 10
  • 11. Libcontainer and LibCTLibcontainer and LibCT ● In Go / In C ● Both support back-ends ● Only Go / binding for other languages ● Easy for developing / works faster ● No fork() / … Libcontainer → runc
  • 12. LibCT APILibCT API 12 Session - create() - load() Container - namespaces - cgroups Process - kill(), wait() ProcessDesc - Uid, Git, Groups
  • 13. ExampleExample s = libct_session_open_local(); /* configure container */ ct = libct_container_create(s, "test"); libct_container_set_nsmask(ct, CLONE_NEWPID | CLONE_NEWUSER | CLONE_NEWNS)); libct_userns_add_uid_map(ct, 0, getuid(), 1); libct_userns_add_gid_map(ct, 0, getgid(), 1); libct_fs_add_mount(ct, "tmpfs", "/tmp", 0, "tmpfs", NULL)) /* configure process descriptor */ p = libct_process_desc_create(s); libct_process_desc_set_caps(p, 0, CAPS_ALL); /* Executing process*/ pr = libct_container_spawn_cb(ct, p, set_ct_alive, ct_alive); libct_process_wait(pr, &status); libct_container_destroy(ct); libct_session_close(s); 13
  • 14. Future plansFuture plans ● Integration with applications ● Noti<cations ● Task-less containers ● Checkpoint/Restore (CRIU)
  • 15. Thank You! Andrey Vagin <avagin@openvz.org> https://github.com/avagin/libct Andrey Vagin <avagin@openvz.org> https://github.com/avagin/libct