SlideShare a Scribd company logo
Rooting out Root:
User namespaces in Docker
Phil Estes
Senior Technical Staff Member, Open Technologies, IBM Cloud
ContainerCon 2015
@estesp
estesp@gmail.com
I work for IBM’s Cloud division
We have a large organization focused on open cloud technologies,
including CloudFoundry, OpenStack, and Docker.
I have been working upstream in the Docker community since July
2014, and am currently a Docker core maintainer.
I have interests in runC (IBM is a founding member of OCI),
libnetwork, and the docker/distribution project (Registry v2)
Trivia: I worked in IBM’s Linux Technology Center for over 10 years!
Hello!
ContainerCon 2015
2
Why user namespaces?
Unprivileged Root
Currently, by default,
the user inside the
container is root;
more specifically uid
= 0, gid = 0. If a
breakout were to
occur, the container
user is root on the
host system.
Multitenancy
Sharing Docker
compute resources
among more than
one user requires
isolation between
tenants. Providing
uid/gid ranges per
tenant will allow for
this separation.
User Accounting
Any per-user
accounting
capabilities are
useless if everyone is
root. Specifying
unique uids enables
resource limitations
specific to a
user/uid.
ContainerCon 2015
3
Deprivileged Root
4
ContainerCon 2015
$ docker run -v /bin:/host/bin -ti busybox /bin/sh
/ # id
uid=0(root) gid=0(root) groups=10(wheel)
/ # cd /host/bin
/host/bin # mv sh old
mv: can't rename 'sh': Permission denied
/host/bin # cp /bin/busybox ./sh
cp: can't create './sh': File exists
Host root ≠ Container root
Multitenant Services
5
ContainerCon 2015
root 0 3000
daemon 1 3001
bin 2 3002
mail 8 3008
www-data 33 3033
dbus 81 3081
root 0 4000
daemon 5 4005
bin 6 4006
mail 12 4012
www-data 55 4055
dbus 84 4084
Tenant A Tenant B
Full UID and GID namespace separation
between tenants in the same hosted cloud
User Accounting/Limits
6
ContainerCon 2015
$ ulimit -n
2048
$ docker run lotsofiles
# of Open Files Limit:
1024
----------------------
Can't open temp file #1021, error: open
/tmp/zzz378562286: too many open files
Container root uid = 2000
User Accounting/Limits
7
ContainerCon 2015
$ ulimit -n
2048
$ docker run lotsofiles
# of Open Files Limit:
1024
----------------------
Can't open temp file #1021, error: open
/tmp/zzz378562286: too many open files
Container root uid = 2000
Wrong!
Docker Security
User namespaces are only one piece of the puzzle.
AppArmor/SELinux, Notary, image security, and
proper environment/network security all play a
part in the overall Docker security picture.
ContainerCon 2015
8
Linux user namespaces
◉ Available as a clone() flag [CLONE_NEWUSER] in Linux
kernel 3.8 (some work completed in 3.9)
◉ Per-process namespace to map user and group IDs to a
specified set of numeric ranges
ContainerCon 2015
uid = 1000
gid = 1000 pid = 8899
uid = 0
gid = 0
clone(.., .. | CLONE_NEWUSER)
parent process
9
“
“Most notably, a process can have a nonzero user ID outside a
namespace while at the same time having a user ID of zero inside
the namespace; in other words, the process is unprivileged for
operations outside the user namespace but has root privileges
inside the namespace.”
https://lwn.net/Articles/532593/
Michael Kerrisk, February 27, 2013
ContainerCon 2015
10
User namespaces and Go
◉ Available since Go version 1.4.0 (October 2014) as fields
within the syscall.SysProcAttr structure: arrays
UidMappings and GidMappings
◉ Thanks to good work from Mrunal Patel and Michael
Crosby laying the Go-lang groundwork for user
namespace capability within Docker/libcontainer
ContainerCon 2015
( https://github.com/golang/go/issues/8447 )
11
Go user namespaces example
ContainerCon 2015
var sys *syscall.SysProcAttr
sys.UidMappings = []syscall.SysProcIDMap{{
ContainerID: 0,
HostID: 1000,
Size: 1,
}}
sys.GidMappings = []syscall.SysProcIDMap{{
ContainerID: 0,
HostID: 1000,
Size: 1,
}}
sys.Cloneflags = syscall.CLONE_NEWUSER
cmd := exec.Cmd{
Path: "/bin/bash",
SysProcAttr: sys,
}
When we run this code
we’ll have a command
that, when executed,
will appear to be
running as root
(uid/gid = 0), but will
actually be the non-
privileged user with
uid/gid = 1000
mapped inside the user
namespace to root.
12
What’s the holdup?
At this point you might be asking
yourself: “So why doesn’t Docker
have user namespace support yet!?”
Let’s take a deeper look at some of
the challenges...
Well, that was easy!
ContainerCon 2015
13
File Ownership
Who can read the metadata, image layers, and associated files across
Docker’s runtime store?
1
ContainerCon 2015
14
Docker Filesystem Hierarchy
ContainerCon 2015
drwx------ root:root /var/lib/docker
drwx------ root:root /var/lib/docker/containers
drwx------ root:root /var/lib/docker/aufs
btrfs
devicemapper
overlay
vfs
zfs
drwx------ root:root /var/lib/docker/{tmp, volumes, ..}
Docker’s metadata tree is rooted
(by default) at /var/lib/docker
and only accessible to user root
The container metadata also
contains files which are bind-
mounted into the container as
root:root today
Depending on your chosen
storage driver, the actual layer
content of Docker images will
be placed here in a root-owned
directory path
Other various locations exist
which may need to be accessed
by container processes 15
File Ownership Solution
◉ At Docker daemon startup, if remapped root is enabled,
create a new subtree owned by the remapped root’s
uid and gid
◉ Whenever the Docker daemon components create a
directory structure, take remapped root into account
◉ This solves an additional issue around file ownership
that we’ll discuss next
ContainerCon 2015
# docker daemon --root=2000:2000 ...
drwxr-xr-x root:root /var/lib/docker
drwx------ 2000:2000 /var/lib/docker/2000.2000
16
Layer Sharing
Docker images are downloaded to the local daemon’s cache from a
registry and expanded into the storage driver’s subtree by ID
2
ContainerCon 2015
17
Docker Image Layer Details
ContainerCon 2015
FROM ubuntu:15.04
…
RUN apt-get install libdevmapper 
libdevmapper-dev
…
COPY issue crontab /etc/
b3ef6
98a5f
55b9d
-rw-r--r-- root:root /etc/issue
-rw-r--r-- root:root /etc/crontab
-rwxr-xr-x root:root /bin/sh
-rwxr-xr-x root:root /bin/ip
-r-xr-xr-x root:root /lib/libdevmapper.so.1.02
-r--r--r-- root:root /usr/lib/libdevmapper.a
useless:1.0
b3ef6
98a5f
55b9d
79cc4
b3ef6
98a5f
55b9d
cc4af
docker run useless:1.0 /bin/sh
docker run useless:1.0 /bin/sh
18
Layer Sharing Solution
Given:
◉ Already mentioned: one metadata subtree per
remapped root
◉ Remapped root setting is daemon-wide (for all
containers running in this instance)
Therefore we:
◉ Untar all layers per the user namespace uid/gid
mapping provided at daemon start
◉ All layers are usable (correct ownership) by any
container in this daemon instance
ContainerCon 2015
restriction?
19
Pros
No ugly chown -R uid:gid
<huge file tree> work to
do at container start time.
For a daemon-wide user
namespace setting, this
solution works perfectly for
the general “don’t be root”
case.
Layer Solution Pros/Cons
Cons
Restarting the daemon
with/without remapped
roots resets the metadata
cache (must re-pull images,
no prior container history)
Some increased disk cost if
daemon is started with
unique remappings or turned
on/off
ContainerCon 2015
20
Namespace Order
When not using clone() to create all namespaces, joining other
namespace types (PID, UTC, Network) may not work properly
depending on the order of operations
3
ContainerCon 2015
21
Namespace Sharing/Ordering
◉ Joining a namespace (e.g. network) which was not
created in the context of a user namespace will not
work as expected.
◉ Prior to Docker 1.7, this meant --net=<container> was
impacted by adding the user namespace function.
◉ In Docker 1.7, libnetwork took over the role of Linux
network namespace creation, introducing the same
ordering problem as --net=<container>
◉ These issues are being resolved now; more info in https:
//github.com/docker/docker/issues/15187
ContainerCon 2015
22
ContainerCon 2015
So where are we now?
User namespace support in Linux kernel 3.8 (early 2013)
User namespace support in Go 1.4 (December 2014)
User namespace support in libcontainer (February 2015)
23
User Namespace Status
◉ Namespace sharing/ordering details & design are resolved;
implementation/changes underway in runC and libnetwork
> runC hooks PR: https://github.com/opencontainers/runc/pull/160
> libnetwork tracker: https://github.com/docker/libnetwork/issues/429
◉ “Phase 1” user namespace implementation (remapped root
per daemon instance) targeted for Docker 1.9
> tracking issue: https://github.com/docker/docker/issues/15187
> code PR: https://github.com/docker/docker/pull/12648
◉ “Phase 2”--providing full maps and allowing per-container
maps--is still under discussion
ContainerCon 2015
24
“Phase 1” Usage Overview
ContainerCon 2015
# docker daemon --root=2000:2000 ...
drwxr-xr-x root:root /var/lib/docker
drwx------ 2000:2000 /var/lib/docker/2000.2000
$ docker run -ti --name fred --rm busybox /bin/sh
/ # id
uid=0(root) gid=0(root) groups=10(wheel)
$ docker inspect -f ‘{{ .State.Pid }}’ fred
8851
$ ps -u 2000
PID TTY TIME CMD
8851 pts/7 00:00:00 sh
Start the daemon with a remapped root
setting (in this case uid/gid = 2000/2000)
Start a container and verify that inside the
container the uid/gid map to root (0/0)
You can verify that the container process
(PID) is actually running as user 2000
25
Any questions?
Thanks!
26
@estesp
github.com/estesp
estesp@gmail.com
http://integratedcode.us
Credits
Special thanks to all the people who made and
released these awesome resources for free:
◉ Presentation template by SlidesCarnival
27

More Related Content

What's hot

Veer's Container Security
Veer's Container SecurityVeer's Container Security
Veer's Container Security
Jim Barlow
 
Docker Security in Production Overview
Docker Security in Production OverviewDocker Security in Production Overview
Docker Security in Production Overview
Delve Labs
 
Oscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to ProductionOscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to Production
Patrick Chanezon
 
Linux Container Technology 101
Linux Container Technology 101Linux Container Technology 101
Linux Container Technology 101
inside-BigData.com
 
Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?
Michael Boelen
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
Layne Peng
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
Walid Ashraf
 
Hands on introduction to docker security for docker newbies
Hands on introduction to docker security for docker newbiesHands on introduction to docker security for docker newbies
Hands on introduction to docker security for docker newbies
Yigal Elefant
 
Docker Security Overview
Docker Security OverviewDocker Security Overview
Docker Security Overview
Sreenivas Makam
 
Docker allocating resources
Docker allocating resourcesDocker allocating resources
Docker allocating resources
Mohammadreza Amini
 
Introduction to docker security
Introduction to docker securityIntroduction to docker security
Introduction to docker security
Walid Ashraf
 
dockerizing web application
dockerizing web applicationdockerizing web application
dockerizing web application
Walid Ashraf
 
KVM and docker LXC Benchmarking with OpenStack
KVM and docker LXC Benchmarking with OpenStackKVM and docker LXC Benchmarking with OpenStack
KVM and docker LXC Benchmarking with OpenStack
Boden Russell
 
CLI Wizardry - A Friendly Intro To sed/awk/grep
CLI Wizardry - A Friendly Intro To sed/awk/grepCLI Wizardry - A Friendly Intro To sed/awk/grep
CLI Wizardry - A Friendly Intro To sed/awk/grep
All Things Open
 
Docker security introduction-task-2016
Docker security introduction-task-2016Docker security introduction-task-2016
Docker security introduction-task-2016
Ricardo Gerardi
 
Tokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker SecurityTokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker Security
Phil Estes
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
Dr. Syed Hassan Amin
 
Container security
Container securityContainer security
Container security
Anthony Chow
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
dotCloud
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
Sreenivas Makam
 

What's hot (20)

Veer's Container Security
Veer's Container SecurityVeer's Container Security
Veer's Container Security
 
Docker Security in Production Overview
Docker Security in Production OverviewDocker Security in Production Overview
Docker Security in Production Overview
 
Oscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to ProductionOscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to Production
 
Linux Container Technology 101
Linux Container Technology 101Linux Container Technology 101
Linux Container Technology 101
 
Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
Hands on introduction to docker security for docker newbies
Hands on introduction to docker security for docker newbiesHands on introduction to docker security for docker newbies
Hands on introduction to docker security for docker newbies
 
Docker Security Overview
Docker Security OverviewDocker Security Overview
Docker Security Overview
 
Docker allocating resources
Docker allocating resourcesDocker allocating resources
Docker allocating resources
 
Introduction to docker security
Introduction to docker securityIntroduction to docker security
Introduction to docker security
 
dockerizing web application
dockerizing web applicationdockerizing web application
dockerizing web application
 
KVM and docker LXC Benchmarking with OpenStack
KVM and docker LXC Benchmarking with OpenStackKVM and docker LXC Benchmarking with OpenStack
KVM and docker LXC Benchmarking with OpenStack
 
CLI Wizardry - A Friendly Intro To sed/awk/grep
CLI Wizardry - A Friendly Intro To sed/awk/grepCLI Wizardry - A Friendly Intro To sed/awk/grep
CLI Wizardry - A Friendly Intro To sed/awk/grep
 
Docker security introduction-task-2016
Docker security introduction-task-2016Docker security introduction-task-2016
Docker security introduction-task-2016
 
Tokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker SecurityTokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker Security
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
 
Container security
Container securityContainer security
Container security
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
 

Viewers also liked

ContainerDays Boston 2016: "Autopilot: Running Real-world Applications in Con...
ContainerDays Boston 2016: "Autopilot: Running Real-world Applications in Con...ContainerDays Boston 2016: "Autopilot: Running Real-world Applications in Con...
ContainerDays Boston 2016: "Autopilot: Running Real-world Applications in Con...
DynamicInfraDays
 
Du craft chez les OPS
Du craft chez les OPSDu craft chez les OPS
Du craft chez les OPS
François Xavier Vende
 
ContentCal AutoPilot
ContentCal AutoPilotContentCal AutoPilot
ContentCal AutoPilot
Andy Lambert
 
Managing AWS infrastructure using CloudFormation
Managing AWS infrastructure using CloudFormationManaging AWS infrastructure using CloudFormation
Managing AWS infrastructure using CloudFormation
Anton Babenko
 
The Container Revolution: Reflections after the first decade
The Container Revolution: Reflections after the first decadeThe Container Revolution: Reflections after the first decade
The Container Revolution: Reflections after the first decade
bcantrill
 
The State of Cloud 2016: The whirlwind of creative destruction
The State of Cloud 2016: The whirlwind of creative destructionThe State of Cloud 2016: The whirlwind of creative destruction
The State of Cloud 2016: The whirlwind of creative destruction
bcantrill
 
Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)
Radek Simko
 
DEVNET-1144 Deploying hybrid cloud applications with HashiCorp Atlas
DEVNET-1144	Deploying hybrid cloud applications with HashiCorp AtlasDEVNET-1144	Deploying hybrid cloud applications with HashiCorp Atlas
DEVNET-1144 Deploying hybrid cloud applications with HashiCorp Atlas
Cisco DevNet
 

Viewers also liked (8)

ContainerDays Boston 2016: "Autopilot: Running Real-world Applications in Con...
ContainerDays Boston 2016: "Autopilot: Running Real-world Applications in Con...ContainerDays Boston 2016: "Autopilot: Running Real-world Applications in Con...
ContainerDays Boston 2016: "Autopilot: Running Real-world Applications in Con...
 
Du craft chez les OPS
Du craft chez les OPSDu craft chez les OPS
Du craft chez les OPS
 
ContentCal AutoPilot
ContentCal AutoPilotContentCal AutoPilot
ContentCal AutoPilot
 
Managing AWS infrastructure using CloudFormation
Managing AWS infrastructure using CloudFormationManaging AWS infrastructure using CloudFormation
Managing AWS infrastructure using CloudFormation
 
The Container Revolution: Reflections after the first decade
The Container Revolution: Reflections after the first decadeThe Container Revolution: Reflections after the first decade
The Container Revolution: Reflections after the first decade
 
The State of Cloud 2016: The whirlwind of creative destruction
The State of Cloud 2016: The whirlwind of creative destructionThe State of Cloud 2016: The whirlwind of creative destruction
The State of Cloud 2016: The whirlwind of creative destruction
 
Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)
 
DEVNET-1144 Deploying hybrid cloud applications with HashiCorp Atlas
DEVNET-1144	Deploying hybrid cloud applications with HashiCorp AtlasDEVNET-1144	Deploying hybrid cloud applications with HashiCorp Atlas
DEVNET-1144 Deploying hybrid cloud applications with HashiCorp Atlas
 

Similar to Rooting Out Root: User namespaces in Docker

Docker Belgium Meetup
Docker Belgium MeetupDocker Belgium Meetup
Docker Belgium Meetup
Phil Estes
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
Carlo Bonamico
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned
RightScale
 
Docker London: Container Security
Docker London: Container SecurityDocker London: Container Security
Docker London: Container Security
Phil Estes
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
Vincent De Smet
 
Faster and Easier Software Development using Docker Platform
Faster and Easier Software Development using Docker PlatformFaster and Easier Software Development using Docker Platform
Faster and Easier Software Development using Docker Platform
msyukor
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇
Philip Zheng
 
ABCs of docker
ABCs of dockerABCs of docker
ABCs of docker
Sabyrzhan Tynybayev
 
Dev opsec dockerimage_patch_n_lifecyclemanagement_
Dev opsec dockerimage_patch_n_lifecyclemanagement_Dev opsec dockerimage_patch_n_lifecyclemanagement_
Dev opsec dockerimage_patch_n_lifecyclemanagement_
kanedafromparis
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Swaminathan Vetri
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
Araf Karsh Hamid
 
Docker Ecosystem on Azure
Docker Ecosystem on AzureDocker Ecosystem on Azure
Docker Ecosystem on Azure
Patrick Chanezon
 
BBL Premiers pas avec Docker
BBL Premiers pas avec DockerBBL Premiers pas avec Docker
BBL Premiers pas avec Docker
kanedafromparis
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017
Paul Chao
 
Docker dDessi november 2015
Docker dDessi november 2015Docker dDessi november 2015
Docker dDessi november 2015
Massimiliano Dessì
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇
Philip Zheng
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
Paul Chao
 
Docker - Der Wal in der Kiste
Docker - Der Wal in der KisteDocker - Der Wal in der Kiste
Docker - Der Wal in der Kiste
Ulrich Krause
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
Roman Rodomansky
 

Similar to Rooting Out Root: User namespaces in Docker (20)

Docker Belgium Meetup
Docker Belgium MeetupDocker Belgium Meetup
Docker Belgium Meetup
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned
 
Docker London: Container Security
Docker London: Container SecurityDocker London: Container Security
Docker London: Container Security
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
 
Faster and Easier Software Development using Docker Platform
Faster and Easier Software Development using Docker PlatformFaster and Easier Software Development using Docker Platform
Faster and Easier Software Development using Docker Platform
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇
 
ABCs of docker
ABCs of dockerABCs of docker
ABCs of docker
 
Dev opsec dockerimage_patch_n_lifecyclemanagement_
Dev opsec dockerimage_patch_n_lifecyclemanagement_Dev opsec dockerimage_patch_n_lifecyclemanagement_
Dev opsec dockerimage_patch_n_lifecyclemanagement_
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
Docker Ecosystem on Azure
Docker Ecosystem on AzureDocker Ecosystem on Azure
Docker Ecosystem on Azure
 
BBL Premiers pas avec Docker
BBL Premiers pas avec DockerBBL Premiers pas avec Docker
BBL Premiers pas avec Docker
 
手把手帶你學Docker 03042017
手把手帶你學Docker 03042017手把手帶你學Docker 03042017
手把手帶你學Docker 03042017
 
Docker dDessi november 2015
Docker dDessi november 2015Docker dDessi november 2015
Docker dDessi november 2015
 
手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇手把手帶你學 Docker 入門篇
手把手帶你學 Docker 入門篇
 
Docker workshop 0507 Taichung
Docker workshop 0507 Taichung Docker workshop 0507 Taichung
Docker workshop 0507 Taichung
 
Docker - Der Wal in der Kiste
Docker - Der Wal in der KisteDocker - Der Wal in der Kiste
Docker - Der Wal in der Kiste
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
 

More from Phil Estes

Enabling Security via Container Runtimes
Enabling Security via Container RuntimesEnabling Security via Container Runtimes
Enabling Security via Container Runtimes
Phil Estes
 
Extended and embedding: containerd update & project use cases
Extended and embedding: containerd update & project use casesExtended and embedding: containerd update & project use cases
Extended and embedding: containerd update & project use cases
Phil Estes
 
Cloud Native TLV Meetup: Securing Containerized Applications Primer
Cloud Native TLV Meetup: Securing Containerized Applications PrimerCloud Native TLV Meetup: Securing Containerized Applications Primer
Cloud Native TLV Meetup: Securing Containerized Applications Primer
Phil Estes
 
Securing Containerized Applications: A Primer
Securing Containerized Applications: A PrimerSecuring Containerized Applications: A Primer
Securing Containerized Applications: A Primer
Phil Estes
 
Securing Containerized Applications: A Primer
Securing Containerized Applications: A PrimerSecuring Containerized Applications: A Primer
Securing Containerized Applications: A Primer
Phil Estes
 
Let's Try Every CRI Runtime Available for Kubernetes
Let's Try Every CRI Runtime Available for KubernetesLet's Try Every CRI Runtime Available for Kubernetes
Let's Try Every CRI Runtime Available for Kubernetes
Phil Estes
 
CraftConf 2019: CRI Runtimes Deep Dive: Who Is Running My Pod?
CraftConf 2019:  CRI Runtimes Deep Dive: Who Is Running My Pod?CraftConf 2019:  CRI Runtimes Deep Dive: Who Is Running My Pod?
CraftConf 2019: CRI Runtimes Deep Dive: Who Is Running My Pod?
Phil Estes
 
JAX Con 2019: Containers. Microservices. Cloud. Open Source. Fantasy or Reali...
JAX Con 2019: Containers. Microservices. Cloud. Open Source. Fantasy or Reali...JAX Con 2019: Containers. Microservices. Cloud. Open Source. Fantasy or Reali...
JAX Con 2019: Containers. Microservices. Cloud. Open Source. Fantasy or Reali...
Phil Estes
 
Giving Back to Upstream | DockerCon 2019
Giving Back to Upstream | DockerCon 2019Giving Back to Upstream | DockerCon 2019
Giving Back to Upstream | DockerCon 2019
Phil Estes
 
What's Running My Containers? A review of runtimes and standards.
What's Running My Containers? A review of runtimes and standards.What's Running My Containers? A review of runtimes and standards.
What's Running My Containers? A review of runtimes and standards.
Phil Estes
 
Docker London Meetup: Docker Engine Evolution
Docker London Meetup: Docker Engine EvolutionDocker London Meetup: Docker Engine Evolution
Docker London Meetup: Docker Engine Evolution
Phil Estes
 
FOSDEM 2019: A containerd Project Update
FOSDEM 2019: A containerd Project UpdateFOSDEM 2019: A containerd Project Update
FOSDEM 2019: A containerd Project Update
Phil Estes
 
CRI Runtimes Deep-Dive: Who's Running My Pod!?
CRI Runtimes Deep-Dive: Who's Running My Pod!?CRI Runtimes Deep-Dive: Who's Running My Pod!?
CRI Runtimes Deep-Dive: Who's Running My Pod!?
Phil Estes
 
Docker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use CasesDocker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use Cases
Phil Estes
 
It's 2018. Are My Containers Secure Yet!?
It's 2018. Are My Containers Secure Yet!?It's 2018. Are My Containers Secure Yet!?
It's 2018. Are My Containers Secure Yet!?
Phil Estes
 
Docker Engine Evolution: From Monolith to Discrete Components
Docker Engine Evolution: From Monolith to Discrete ComponentsDocker Engine Evolution: From Monolith to Discrete Components
Docker Engine Evolution: From Monolith to Discrete Components
Phil Estes
 
An Open Source Story: Open Containers & Open Communities
An Open Source Story: Open Containers & Open CommunitiesAn Open Source Story: Open Containers & Open Communities
An Open Source Story: Open Containers & Open Communities
Phil Estes
 
Whose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
Whose Job Is It Anyway? Kubernetes, CRI, & Container RuntimesWhose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
Whose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
Phil Estes
 
Containerd Project Update: FOSDEM 2018
Containerd Project Update: FOSDEM 2018Containerd Project Update: FOSDEM 2018
Containerd Project Update: FOSDEM 2018
Phil Estes
 
Embedding Containerd For Fun and Profit
Embedding Containerd For Fun and ProfitEmbedding Containerd For Fun and Profit
Embedding Containerd For Fun and Profit
Phil Estes
 

More from Phil Estes (20)

Enabling Security via Container Runtimes
Enabling Security via Container RuntimesEnabling Security via Container Runtimes
Enabling Security via Container Runtimes
 
Extended and embedding: containerd update & project use cases
Extended and embedding: containerd update & project use casesExtended and embedding: containerd update & project use cases
Extended and embedding: containerd update & project use cases
 
Cloud Native TLV Meetup: Securing Containerized Applications Primer
Cloud Native TLV Meetup: Securing Containerized Applications PrimerCloud Native TLV Meetup: Securing Containerized Applications Primer
Cloud Native TLV Meetup: Securing Containerized Applications Primer
 
Securing Containerized Applications: A Primer
Securing Containerized Applications: A PrimerSecuring Containerized Applications: A Primer
Securing Containerized Applications: A Primer
 
Securing Containerized Applications: A Primer
Securing Containerized Applications: A PrimerSecuring Containerized Applications: A Primer
Securing Containerized Applications: A Primer
 
Let's Try Every CRI Runtime Available for Kubernetes
Let's Try Every CRI Runtime Available for KubernetesLet's Try Every CRI Runtime Available for Kubernetes
Let's Try Every CRI Runtime Available for Kubernetes
 
CraftConf 2019: CRI Runtimes Deep Dive: Who Is Running My Pod?
CraftConf 2019:  CRI Runtimes Deep Dive: Who Is Running My Pod?CraftConf 2019:  CRI Runtimes Deep Dive: Who Is Running My Pod?
CraftConf 2019: CRI Runtimes Deep Dive: Who Is Running My Pod?
 
JAX Con 2019: Containers. Microservices. Cloud. Open Source. Fantasy or Reali...
JAX Con 2019: Containers. Microservices. Cloud. Open Source. Fantasy or Reali...JAX Con 2019: Containers. Microservices. Cloud. Open Source. Fantasy or Reali...
JAX Con 2019: Containers. Microservices. Cloud. Open Source. Fantasy or Reali...
 
Giving Back to Upstream | DockerCon 2019
Giving Back to Upstream | DockerCon 2019Giving Back to Upstream | DockerCon 2019
Giving Back to Upstream | DockerCon 2019
 
What's Running My Containers? A review of runtimes and standards.
What's Running My Containers? A review of runtimes and standards.What's Running My Containers? A review of runtimes and standards.
What's Running My Containers? A review of runtimes and standards.
 
Docker London Meetup: Docker Engine Evolution
Docker London Meetup: Docker Engine EvolutionDocker London Meetup: Docker Engine Evolution
Docker London Meetup: Docker Engine Evolution
 
FOSDEM 2019: A containerd Project Update
FOSDEM 2019: A containerd Project UpdateFOSDEM 2019: A containerd Project Update
FOSDEM 2019: A containerd Project Update
 
CRI Runtimes Deep-Dive: Who's Running My Pod!?
CRI Runtimes Deep-Dive: Who's Running My Pod!?CRI Runtimes Deep-Dive: Who's Running My Pod!?
CRI Runtimes Deep-Dive: Who's Running My Pod!?
 
Docker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use CasesDocker Athens: Docker Engine Evolution & Containerd Use Cases
Docker Athens: Docker Engine Evolution & Containerd Use Cases
 
It's 2018. Are My Containers Secure Yet!?
It's 2018. Are My Containers Secure Yet!?It's 2018. Are My Containers Secure Yet!?
It's 2018. Are My Containers Secure Yet!?
 
Docker Engine Evolution: From Monolith to Discrete Components
Docker Engine Evolution: From Monolith to Discrete ComponentsDocker Engine Evolution: From Monolith to Discrete Components
Docker Engine Evolution: From Monolith to Discrete Components
 
An Open Source Story: Open Containers & Open Communities
An Open Source Story: Open Containers & Open CommunitiesAn Open Source Story: Open Containers & Open Communities
An Open Source Story: Open Containers & Open Communities
 
Whose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
Whose Job Is It Anyway? Kubernetes, CRI, & Container RuntimesWhose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
Whose Job Is It Anyway? Kubernetes, CRI, & Container Runtimes
 
Containerd Project Update: FOSDEM 2018
Containerd Project Update: FOSDEM 2018Containerd Project Update: FOSDEM 2018
Containerd Project Update: FOSDEM 2018
 
Embedding Containerd For Fun and Profit
Embedding Containerd For Fun and ProfitEmbedding Containerd For Fun and Profit
Embedding Containerd For Fun and Profit
 

Recently uploaded

Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 

Recently uploaded (20)

Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 

Rooting Out Root: User namespaces in Docker

  • 1. Rooting out Root: User namespaces in Docker Phil Estes Senior Technical Staff Member, Open Technologies, IBM Cloud ContainerCon 2015 @estesp estesp@gmail.com
  • 2. I work for IBM’s Cloud division We have a large organization focused on open cloud technologies, including CloudFoundry, OpenStack, and Docker. I have been working upstream in the Docker community since July 2014, and am currently a Docker core maintainer. I have interests in runC (IBM is a founding member of OCI), libnetwork, and the docker/distribution project (Registry v2) Trivia: I worked in IBM’s Linux Technology Center for over 10 years! Hello! ContainerCon 2015 2
  • 3. Why user namespaces? Unprivileged Root Currently, by default, the user inside the container is root; more specifically uid = 0, gid = 0. If a breakout were to occur, the container user is root on the host system. Multitenancy Sharing Docker compute resources among more than one user requires isolation between tenants. Providing uid/gid ranges per tenant will allow for this separation. User Accounting Any per-user accounting capabilities are useless if everyone is root. Specifying unique uids enables resource limitations specific to a user/uid. ContainerCon 2015 3
  • 4. Deprivileged Root 4 ContainerCon 2015 $ docker run -v /bin:/host/bin -ti busybox /bin/sh / # id uid=0(root) gid=0(root) groups=10(wheel) / # cd /host/bin /host/bin # mv sh old mv: can't rename 'sh': Permission denied /host/bin # cp /bin/busybox ./sh cp: can't create './sh': File exists Host root ≠ Container root
  • 5. Multitenant Services 5 ContainerCon 2015 root 0 3000 daemon 1 3001 bin 2 3002 mail 8 3008 www-data 33 3033 dbus 81 3081 root 0 4000 daemon 5 4005 bin 6 4006 mail 12 4012 www-data 55 4055 dbus 84 4084 Tenant A Tenant B Full UID and GID namespace separation between tenants in the same hosted cloud
  • 6. User Accounting/Limits 6 ContainerCon 2015 $ ulimit -n 2048 $ docker run lotsofiles # of Open Files Limit: 1024 ---------------------- Can't open temp file #1021, error: open /tmp/zzz378562286: too many open files Container root uid = 2000
  • 7. User Accounting/Limits 7 ContainerCon 2015 $ ulimit -n 2048 $ docker run lotsofiles # of Open Files Limit: 1024 ---------------------- Can't open temp file #1021, error: open /tmp/zzz378562286: too many open files Container root uid = 2000 Wrong!
  • 8. Docker Security User namespaces are only one piece of the puzzle. AppArmor/SELinux, Notary, image security, and proper environment/network security all play a part in the overall Docker security picture. ContainerCon 2015 8
  • 9. Linux user namespaces ◉ Available as a clone() flag [CLONE_NEWUSER] in Linux kernel 3.8 (some work completed in 3.9) ◉ Per-process namespace to map user and group IDs to a specified set of numeric ranges ContainerCon 2015 uid = 1000 gid = 1000 pid = 8899 uid = 0 gid = 0 clone(.., .. | CLONE_NEWUSER) parent process 9
  • 10. “ “Most notably, a process can have a nonzero user ID outside a namespace while at the same time having a user ID of zero inside the namespace; in other words, the process is unprivileged for operations outside the user namespace but has root privileges inside the namespace.” https://lwn.net/Articles/532593/ Michael Kerrisk, February 27, 2013 ContainerCon 2015 10
  • 11. User namespaces and Go ◉ Available since Go version 1.4.0 (October 2014) as fields within the syscall.SysProcAttr structure: arrays UidMappings and GidMappings ◉ Thanks to good work from Mrunal Patel and Michael Crosby laying the Go-lang groundwork for user namespace capability within Docker/libcontainer ContainerCon 2015 ( https://github.com/golang/go/issues/8447 ) 11
  • 12. Go user namespaces example ContainerCon 2015 var sys *syscall.SysProcAttr sys.UidMappings = []syscall.SysProcIDMap{{ ContainerID: 0, HostID: 1000, Size: 1, }} sys.GidMappings = []syscall.SysProcIDMap{{ ContainerID: 0, HostID: 1000, Size: 1, }} sys.Cloneflags = syscall.CLONE_NEWUSER cmd := exec.Cmd{ Path: "/bin/bash", SysProcAttr: sys, } When we run this code we’ll have a command that, when executed, will appear to be running as root (uid/gid = 0), but will actually be the non- privileged user with uid/gid = 1000 mapped inside the user namespace to root. 12
  • 13. What’s the holdup? At this point you might be asking yourself: “So why doesn’t Docker have user namespace support yet!?” Let’s take a deeper look at some of the challenges... Well, that was easy! ContainerCon 2015 13
  • 14. File Ownership Who can read the metadata, image layers, and associated files across Docker’s runtime store? 1 ContainerCon 2015 14
  • 15. Docker Filesystem Hierarchy ContainerCon 2015 drwx------ root:root /var/lib/docker drwx------ root:root /var/lib/docker/containers drwx------ root:root /var/lib/docker/aufs btrfs devicemapper overlay vfs zfs drwx------ root:root /var/lib/docker/{tmp, volumes, ..} Docker’s metadata tree is rooted (by default) at /var/lib/docker and only accessible to user root The container metadata also contains files which are bind- mounted into the container as root:root today Depending on your chosen storage driver, the actual layer content of Docker images will be placed here in a root-owned directory path Other various locations exist which may need to be accessed by container processes 15
  • 16. File Ownership Solution ◉ At Docker daemon startup, if remapped root is enabled, create a new subtree owned by the remapped root’s uid and gid ◉ Whenever the Docker daemon components create a directory structure, take remapped root into account ◉ This solves an additional issue around file ownership that we’ll discuss next ContainerCon 2015 # docker daemon --root=2000:2000 ... drwxr-xr-x root:root /var/lib/docker drwx------ 2000:2000 /var/lib/docker/2000.2000 16
  • 17. Layer Sharing Docker images are downloaded to the local daemon’s cache from a registry and expanded into the storage driver’s subtree by ID 2 ContainerCon 2015 17
  • 18. Docker Image Layer Details ContainerCon 2015 FROM ubuntu:15.04 … RUN apt-get install libdevmapper libdevmapper-dev … COPY issue crontab /etc/ b3ef6 98a5f 55b9d -rw-r--r-- root:root /etc/issue -rw-r--r-- root:root /etc/crontab -rwxr-xr-x root:root /bin/sh -rwxr-xr-x root:root /bin/ip -r-xr-xr-x root:root /lib/libdevmapper.so.1.02 -r--r--r-- root:root /usr/lib/libdevmapper.a useless:1.0 b3ef6 98a5f 55b9d 79cc4 b3ef6 98a5f 55b9d cc4af docker run useless:1.0 /bin/sh docker run useless:1.0 /bin/sh 18
  • 19. Layer Sharing Solution Given: ◉ Already mentioned: one metadata subtree per remapped root ◉ Remapped root setting is daemon-wide (for all containers running in this instance) Therefore we: ◉ Untar all layers per the user namespace uid/gid mapping provided at daemon start ◉ All layers are usable (correct ownership) by any container in this daemon instance ContainerCon 2015 restriction? 19
  • 20. Pros No ugly chown -R uid:gid <huge file tree> work to do at container start time. For a daemon-wide user namespace setting, this solution works perfectly for the general “don’t be root” case. Layer Solution Pros/Cons Cons Restarting the daemon with/without remapped roots resets the metadata cache (must re-pull images, no prior container history) Some increased disk cost if daemon is started with unique remappings or turned on/off ContainerCon 2015 20
  • 21. Namespace Order When not using clone() to create all namespaces, joining other namespace types (PID, UTC, Network) may not work properly depending on the order of operations 3 ContainerCon 2015 21
  • 22. Namespace Sharing/Ordering ◉ Joining a namespace (e.g. network) which was not created in the context of a user namespace will not work as expected. ◉ Prior to Docker 1.7, this meant --net=<container> was impacted by adding the user namespace function. ◉ In Docker 1.7, libnetwork took over the role of Linux network namespace creation, introducing the same ordering problem as --net=<container> ◉ These issues are being resolved now; more info in https: //github.com/docker/docker/issues/15187 ContainerCon 2015 22
  • 23. ContainerCon 2015 So where are we now? User namespace support in Linux kernel 3.8 (early 2013) User namespace support in Go 1.4 (December 2014) User namespace support in libcontainer (February 2015) 23
  • 24. User Namespace Status ◉ Namespace sharing/ordering details & design are resolved; implementation/changes underway in runC and libnetwork > runC hooks PR: https://github.com/opencontainers/runc/pull/160 > libnetwork tracker: https://github.com/docker/libnetwork/issues/429 ◉ “Phase 1” user namespace implementation (remapped root per daemon instance) targeted for Docker 1.9 > tracking issue: https://github.com/docker/docker/issues/15187 > code PR: https://github.com/docker/docker/pull/12648 ◉ “Phase 2”--providing full maps and allowing per-container maps--is still under discussion ContainerCon 2015 24
  • 25. “Phase 1” Usage Overview ContainerCon 2015 # docker daemon --root=2000:2000 ... drwxr-xr-x root:root /var/lib/docker drwx------ 2000:2000 /var/lib/docker/2000.2000 $ docker run -ti --name fred --rm busybox /bin/sh / # id uid=0(root) gid=0(root) groups=10(wheel) $ docker inspect -f ‘{{ .State.Pid }}’ fred 8851 $ ps -u 2000 PID TTY TIME CMD 8851 pts/7 00:00:00 sh Start the daemon with a remapped root setting (in this case uid/gid = 2000/2000) Start a container and verify that inside the container the uid/gid map to root (0/0) You can verify that the container process (PID) is actually running as user 2000 25
  • 27. Credits Special thanks to all the people who made and released these awesome resources for free: ◉ Presentation template by SlidesCarnival 27