docker internals

12
Docker Internals Docker Meetup, Mountain View Rohit Jnagal

Upload: rohit-jnagal

Post on 07-Aug-2015

277 views

Category:

Engineering


10 download

TRANSCRIPT

Page 1: Docker internals

Docker Internals

Docker Meetup, Mountain View

Rohit Jnagal

Page 3: Docker internals

Docker 101

Build Once, Configure Once.

Deploy Everything*Everywhere*Reliably & ConsistentlyEfficientlyCheaply

Page 4: Docker internals

Docker Components

Docker Daemon

Libcontainer

cgroups namespaces

AUFS

BTRFS

dm-thinp

VFS

Kernel

User S

pace

Page 5: Docker internals

Docker Components

Page 6: Docker internals

Docker Grounds up: Filesystem

File-system Isolation:Building a rootfs dir and chroot into it.With mount namespace, use pivot-root.

Features:Layering, CoW, Caching, Diffing

Solutions:UnionFS, Snapshotting FS, VFS

AUFS in action

Page 7: Docker internals

Filesystem

Layer 2

Layer 1

Base Image

Writable Layer

Container

Layer 1

Base Image

Writable Layer

Container

Snapshot

Container A Container B

Writable Layer A

Writable Layer B

Layer 2 (e.g. Configuration)

Layer 1 (e.g. MySQL)

Base Image (e.g. Ubuntu)

Shared

Priv

Page 8: Docker internals

Docker Grounds up: Filesystem

From: Jérôme Petazzoni

Page 9: Docker internals

Docker Grounds up: Namespaces

● Process trees.● Mounts.● Network.● User accounts.● Hostnames.● Inter-process

communication.

pid_t pid = clone(..., flags, ...)

CLONE_NEWUTS hostname, domainnameCLONE_NEWIPC IPC objectsCLONE_NEWPID Process IDsCLONE_NEWNET Network configurationCLONE_NEWNS File system mountsCLONE_NEWUSER User and Group IDs

setns(int fd, int nstype)CLONE_NEWIPCCLONE_NEWNETCLONE_NEWUTS

Also: unshare(flags)

Page 10: Docker internals

Docker Grounds up: Resource Isolation

Cgroups : Isolation and accounting● cpu● memory● block i/o● devices● network● numa● freezer

image credit: mairin

Page 11: Docker internals

Docker Grounds up: Add Security

Security Layers

● Linux Capabilities.● User namespaces: Unprivileged users.● nosuid & ro mounts.● Seccomp-bpf● GRSEC and PAX● Device cgroups● Access Control: SELinux & AppArmor● Future: Namespace aware sys/proc

image credit: Leo Reynolds

Page 12: Docker internals

Questions

Thanks,

jnagal@google@jnagal