SlideShare a Scribd company logo
Building a Container Supervisor
Michael
Crosby
Docker since 0.3 - maintainer
dockerui - author
libcontainer - author
nsinit - author
runc - author
OCI - maintainer
containerd - author
> whoami
containerd
● Fast, lightweight container supervisor
● runc (OCI) multiplexer
● Container lifecycle operations
● rm -rf docker/daemon/execdrivers
> man containerd
● runc integration
● Multiple runtime support
● Execution v2
● Decouple Execution from filesystem
● daemonless containers
● cleaner development
> why
● lock free event loop
● concurrency control
○ 10 > 100 at a time
● easier to new developers
> events
Benchmarks
> ./benchmark -count 100
INFO[0001] 1.149902846 seconds
Managing state is easy when you don’t
have any.
Don’t keep anything in memory.
> container state
Restore
> containerd --debug
DEBU[0000] containerd: container restored id=0
DEBU[0000] containerd: container restored id=1
DEBU[0000] containerd: container restored id=2
DEBU[0000] containerd: container restored id=3
DEBU[0000] containerd: container restored id=4
DEBU[0000] containerd: container restored id=5
DEBU[0000] containerd: container restored id=6
...
● Exit code
● TTY / STDIO
● Reparenting to sysinit
> shim
● Pipe + File
● O_CLOEXEC
● Multiple subscribers
> exit status
O_CLOEXEC
if (mkfifo("exit-fifo", 0666) != 0) {
printf("%sn", strerror(errno));
exit(EXIT_FAILURE);
}
int fd = open("exit-fifo", O_WRONLY | O_CLOEXEC, 0);
● FIFOs - the good, bad, and the stupid
● open() never blocks :trollface:
● fifos have a buffer
○ /proc/sys/fs/pipe-max-size
> stdio reattach
● prctl - PR_SET_CHILD_SUBREAPER
● system init
> re-parenting
1. Your parent is the process that forked you, your mommy
2. If your parent dies, your new parent is PID 1*, the creator
3. If the parent(s) of your parent has the subreaper set, they will become
your parent not PID 1, your nana
4. If you die then your parent dies before doing a wait4(), you’re a
zombie
> re-parenting rules
PR_SET_CHILD_SUBREAPER
> ./parent
main() parent 27538
child process 27540 with parent 27539
parent 27539 exiting
child process 27540 with new parent 2391
> ps x | grep 2391
2391 ? Ss 0:00 /sbin/upstart --user
PR_SET_CHILD_SUBREAPER
> ./parent --subreaper
main() parent 27543
child process 27545 with parent 27544
parent 27544 exiting
child process 27545 with new parent 27543
How do you connect to OOM notifications
before the user process starts?
> The OOM Problem
● create
○ initialize namespaces and config
● start
○ exec the user’s process
● delete
○ destroy the container
> runtime workflow
1. Create container
2. Register OOM handler
3. Exec the user's process
> runtime workflow
https://github.com/crosbymichael/dockercon-2016
> code
Thank you!

More Related Content

PDF
Docker 1.11 @ Docker SF Meetup
PDF
runC: The little engine that could (run Docker containers) by Docker Captain ...
PDF
Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...
PDF
What's New in Docker 1.12?
PDF
Docker Orchestration at Production Scale
PDF
Container Orchestration from Theory to Practice
PPTX
Docker Networking in OpenStack: What you need to know now
PDF
Leveraging the Power of containerd Events - Evan Hazlett
Docker 1.11 @ Docker SF Meetup
runC: The little engine that could (run Docker containers) by Docker Captain ...
Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...
What's New in Docker 1.12?
Docker Orchestration at Production Scale
Container Orchestration from Theory to Practice
Docker Networking in OpenStack: What you need to know now
Leveraging the Power of containerd Events - Evan Hazlett

What's hot (20)

PPTX
Docker Networking & Swarm Mode Introduction
PDF
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
PPTX
Comprehensive Monitoring for Docker
PPTX
DCUS17 : Docker networking deep dive
PDF
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
PDF
Breaking the RpiDocker challenge
PDF
Docker swarm introduction
PDF
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
PPTX
Docker 1.11 Presentation
PPTX
Container Monitoring with Sysdig
PPTX
Docker practical solutions
PPTX
Load Balancing Apps in Docker Swarm with NGINX
PDF
Docker orchestration using core os and ansible - Ansible IL 2015
PDF
Troubleshooting Tips from a Docker Support Engineer
PDF
Docker Security Deep Dive by Ying Li and David Lawrence
PPT
Docker Multi Host Networking, Rachit Arora, IBM
PDF
Docker Online Meetup #28: Production-Ready Docker Swarm
PDF
Swarm mode
PPTX
Docker Networking Tip - Macvlan driver
PDF
Container Performance Analysis
Docker Networking & Swarm Mode Introduction
On-Demand Image Resizing from Part of the monolith to Containerized Microserv...
Comprehensive Monitoring for Docker
DCUS17 : Docker networking deep dive
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
Breaking the RpiDocker challenge
Docker swarm introduction
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Docker 1.11 Presentation
Container Monitoring with Sysdig
Docker practical solutions
Load Balancing Apps in Docker Swarm with NGINX
Docker orchestration using core os and ansible - Ansible IL 2015
Troubleshooting Tips from a Docker Support Engineer
Docker Security Deep Dive by Ying Li and David Lawrence
Docker Multi Host Networking, Rachit Arora, IBM
Docker Online Meetup #28: Production-Ready Docker Swarm
Swarm mode
Docker Networking Tip - Macvlan driver
Container Performance Analysis
Ad

Viewers also liked (20)

PDF
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
PPTX
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
PDF
Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov
PDF
Getting Deep on Orchestration: APIs, Actors, and Abstractions in a Distribute...
PDF
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
PDF
Docker for Ops: Extending Docker with APIs, Drivers and Plugins by Arnaud Por...
PDF
Docker for Mac and Windows: The Insider's Guide by Justin Cormack
PDF
Unikernels and docker from revolution to evolution — unikernels and docker ...
PDF
Cloning Running Servers with Docker and CRIU by Ross Boucher
PPTX
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
PPTX
DockerCon 16 General Session Day 1
PPTX
DockerCon 16 General Session Day 2
PPTX
Containerd - core container runtime component
PDF
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
PDF
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
PDF
containerd summit - Deep Dive into containerd
PDF
containerd and CRI
PDF
Docker for Developers - Part 2 by Borja Burgos and Fernando Mayo
PDF
Docker for Developers - Part 1 by David Gageot
PDF
DockerCon SF 2015: Docker Security
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
Sharding Containers: Make Go Apps Computer-Friendly Again by Andrey Sibiryov
Getting Deep on Orchestration: APIs, Actors, and Abstractions in a Distribute...
Microservices + Events + Docker = A Perfect Trio by Docker Captain Chris Rich...
Docker for Ops: Extending Docker with APIs, Drivers and Plugins by Arnaud Por...
Docker for Mac and Windows: The Insider's Guide by Justin Cormack
Unikernels and docker from revolution to evolution — unikernels and docker ...
Cloning Running Servers with Docker and CRIU by Ross Boucher
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
DockerCon 16 General Session Day 1
DockerCon 16 General Session Day 2
Containerd - core container runtime component
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
containerd summit - Deep Dive into containerd
containerd and CRI
Docker for Developers - Part 2 by Borja Burgos and Fernando Mayo
Docker for Developers - Part 1 by David Gageot
DockerCon SF 2015: Docker Security
Ad

Similar to Containerd: Building a Container Supervisor by Michael Crosby (20)

PDF
DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...
PPTX
Percona Live 2022 - PBM - The Backup Open Source Tool for MongoDB
PDF
Training Slides: 203 - Backup & Recovery
PDF
Introduction to Kalabox
PPTX
How to build a container monitoring solution - David Gildeh, CEO and Co-Found...
PDF
Extending Foreman the easy way with foreman_hooks
ODP
Linux Capabilities - eng - v2.1.5, compact
PDF
Setting up Puppet at Colruyt
PDF
FPC for the Masses - CoRIIN 2018
PPTX
Severalnines Training: MySQL Cluster - Part X
PDF
PythonBrasil[8] - CPython for dummies
PPTX
QEMU Sandboxing for dummies
PDF
Kubernetes Story - Day 1: Build and Manage Containers with Podman
PDF
Fosdem_Using_SELinux_with_container_runtimes.pdf
PDF
آموزش مدیریت بانک اطلاعاتی اوراکل - بخش پانزدهم
PDF
Growing pains - PosKeyErrors and other malaises
PDF
Collaborate2011-XtraBackup Collaborate2011-XtraBackup
PPT
9 cm402.13
PPTX
Linux container internals
PDF
learn you some erlang - chap11 to chap12
DEF CON 27 - workshop - GUILLAUME ROSS - defending environments and hunting m...
Percona Live 2022 - PBM - The Backup Open Source Tool for MongoDB
Training Slides: 203 - Backup & Recovery
Introduction to Kalabox
How to build a container monitoring solution - David Gildeh, CEO and Co-Found...
Extending Foreman the easy way with foreman_hooks
Linux Capabilities - eng - v2.1.5, compact
Setting up Puppet at Colruyt
FPC for the Masses - CoRIIN 2018
Severalnines Training: MySQL Cluster - Part X
PythonBrasil[8] - CPython for dummies
QEMU Sandboxing for dummies
Kubernetes Story - Day 1: Build and Manage Containers with Podman
Fosdem_Using_SELinux_with_container_runtimes.pdf
آموزش مدیریت بانک اطلاعاتی اوراکل - بخش پانزدهم
Growing pains - PosKeyErrors and other malaises
Collaborate2011-XtraBackup Collaborate2011-XtraBackup
9 cm402.13
Linux container internals
learn you some erlang - chap11 to chap12

More from Docker, Inc. (20)

PDF
Containerize Your Game Server for the Best Multiplayer Experience
PDF
How to Improve Your Image Builds Using Advance Docker Build
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
Securing Your Containerized Applications with NGINX
PDF
How To Build and Run Node Apps with Docker and Compose
PDF
Hands-on Helm
PDF
Distributed Deep Learning with Docker at Salesforce
PDF
The First 10M Pulls: Building The Official Curl Image for Docker Hub
PDF
Monitoring in a Microservices World
PDF
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
PDF
Predicting Space Weather with Docker
PDF
Become a Docker Power User With Microsoft Visual Studio Code
PDF
How to Use Mirroring and Caching to Optimize your Container Registry
PDF
Monolithic to Microservices + Docker = SDLC on Steroids!
PDF
Kubernetes at Datadog Scale
PDF
Labels, Labels, Labels
PDF
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
PDF
Developing with Docker for the Arm Architecture
Containerize Your Game Server for the Best Multiplayer Experience
How to Improve Your Image Builds Using Advance Docker Build
Build & Deploy Multi-Container Applications to AWS
Securing Your Containerized Applications with NGINX
How To Build and Run Node Apps with Docker and Compose
Hands-on Helm
Distributed Deep Learning with Docker at Salesforce
The First 10M Pulls: Building The Official Curl Image for Docker Hub
Monitoring in a Microservices World
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
Predicting Space Weather with Docker
Become a Docker Power User With Microsoft Visual Studio Code
How to Use Mirroring and Caching to Optimize your Container Registry
Monolithic to Microservices + Docker = SDLC on Steroids!
Kubernetes at Datadog Scale
Labels, Labels, Labels
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Build & Deploy Multi-Container Applications to AWS
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
Developing with Docker for the Arm Architecture

Recently uploaded (20)

PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
KodekX | Application Modernization Development
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
Teaching material agriculture food technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Cloud computing and distributed systems.
PDF
Modernizing your data center with Dell and AMD
PDF
cuic standard and advanced reporting.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Big Data Technologies - Introduction.pptx
Electronic commerce courselecture one. Pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Understanding_Digital_Forensics_Presentation.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Diabetes mellitus diagnosis method based random forest with bat algorithm
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
KodekX | Application Modernization Development
Advanced methodologies resolving dimensionality complications for autism neur...
Teaching material agriculture food technology
20250228 LYD VKU AI Blended-Learning.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Chapter 3 Spatial Domain Image Processing.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Cloud computing and distributed systems.
Modernizing your data center with Dell and AMD
cuic standard and advanced reporting.pdf

Containerd: Building a Container Supervisor by Michael Crosby

  • 1. Building a Container Supervisor Michael Crosby
  • 2. Docker since 0.3 - maintainer dockerui - author libcontainer - author nsinit - author runc - author OCI - maintainer containerd - author > whoami
  • 3. containerd ● Fast, lightweight container supervisor ● runc (OCI) multiplexer ● Container lifecycle operations ● rm -rf docker/daemon/execdrivers > man containerd
  • 4. ● runc integration ● Multiple runtime support ● Execution v2 ● Decouple Execution from filesystem ● daemonless containers ● cleaner development > why
  • 5. ● lock free event loop ● concurrency control ○ 10 > 100 at a time ● easier to new developers > events
  • 6. Benchmarks > ./benchmark -count 100 INFO[0001] 1.149902846 seconds
  • 7. Managing state is easy when you don’t have any. Don’t keep anything in memory. > container state
  • 8. Restore > containerd --debug DEBU[0000] containerd: container restored id=0 DEBU[0000] containerd: container restored id=1 DEBU[0000] containerd: container restored id=2 DEBU[0000] containerd: container restored id=3 DEBU[0000] containerd: container restored id=4 DEBU[0000] containerd: container restored id=5 DEBU[0000] containerd: container restored id=6 ...
  • 9. ● Exit code ● TTY / STDIO ● Reparenting to sysinit > shim
  • 10. ● Pipe + File ● O_CLOEXEC ● Multiple subscribers > exit status
  • 11. O_CLOEXEC if (mkfifo("exit-fifo", 0666) != 0) { printf("%sn", strerror(errno)); exit(EXIT_FAILURE); } int fd = open("exit-fifo", O_WRONLY | O_CLOEXEC, 0);
  • 12. ● FIFOs - the good, bad, and the stupid ● open() never blocks :trollface: ● fifos have a buffer ○ /proc/sys/fs/pipe-max-size > stdio reattach
  • 13. ● prctl - PR_SET_CHILD_SUBREAPER ● system init > re-parenting
  • 14. 1. Your parent is the process that forked you, your mommy 2. If your parent dies, your new parent is PID 1*, the creator 3. If the parent(s) of your parent has the subreaper set, they will become your parent not PID 1, your nana 4. If you die then your parent dies before doing a wait4(), you’re a zombie > re-parenting rules
  • 15. PR_SET_CHILD_SUBREAPER > ./parent main() parent 27538 child process 27540 with parent 27539 parent 27539 exiting child process 27540 with new parent 2391 > ps x | grep 2391 2391 ? Ss 0:00 /sbin/upstart --user
  • 16. PR_SET_CHILD_SUBREAPER > ./parent --subreaper main() parent 27543 child process 27545 with parent 27544 parent 27544 exiting child process 27545 with new parent 27543
  • 17. How do you connect to OOM notifications before the user process starts? > The OOM Problem
  • 18. ● create ○ initialize namespaces and config ● start ○ exec the user’s process ● delete ○ destroy the container > runtime workflow
  • 19. 1. Create container 2. Register OOM handler 3. Exec the user's process > runtime workflow