SlideShare a Scribd company logo
Immutable
infrastructure
with Docker and
containers
1 / 59
Who am I?
Jérôme Petazzoni (@jpetazzo)
French software engineer living in California
Joined Docker (dotCloud) more than 4 years ago
(I was at Docker before it was cool!)
I have built and scaled the dotCloud PaaS
I learned a few things about running containers
(in production)
2 / 59
Outline
What is immutable infrastructure?
What are its pros and cons?
How can it be implemented with containers?
Also: demos!
3 / 59
Immutable
infrastructure
(a.k.a. immutable servers,
phoenix servers, etc.)
4 / 59
Rule 1: never change what's on a server
Don't install new packages
Don't upgrade existing ones
Don't remove or downgrade them
(Even for security vulnerabilities!)
Don't edit configuration files
Don't update your app code
(Even for small or urgent fixes!)
5 / 59
Rule 2: if tempted to change something...
See Rule 1
(OK, we will see an exception later.)
6 / 59
How do we upgrade?
Create new server from scratch
Apply deployment process*
(scripts, configuration management...)
(Optional: test the new server)
Replace old server with new server
Keep old server around, just in case
* Configuration management helps, but is not mandatory here.
7 / 59
WHY?!?
8 / 59
Avoid drift
9 / 59
Avoid drift
10 / 59
Avoid drift
Drift = differences between servers
(when they are supposed to be identical)
Caused by:
provisioning servers at different times
any manual operation
Consequences:
seemingly random failures
same code, different behavior
gets worse with time
11 / 59
Coping with drift
Careful replication of manual operations doesn't scale
(and is error-prone)
Automation seems simple at first,
but has to deal with many edge cases
Configuration management helps,
but only deals with what you've defined
12 / 59
Automation fails
"Let's use parallel-ssh!" (Or your favorite tool)
What if some servers...
are unreachable
become unreachable during the process
are being provisioned at the same time
What if one of those services is (partially) down?
distro package repositories
code or artifact repositories
13 / 59
Config management fails
package{"openssl":ensure=>"installed"}
14 / 59
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
15 / 59
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
16 / 59
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
Something went wrong, abort, abort!
17 / 59
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
Something went wrong, abort, abort!
package{"openssl":ensure=>"installed"}
18 / 59
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
Something went wrong, abort, abort!
package{"openssl":ensure=>"installed"}
We didn't roll back to whatever-we-had!
19 / 59
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
Something went wrong, abort, abort!
package{"openssl":ensure=>"installed"}
We didn't roll back to whatever-we-had!
package{"openssl":ensure=>"1.0.1f"}
20 / 59
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
Something went wrong, abort, abort!
package{"openssl":ensure=>"installed"}
We didn't roll back to whatever-we-had!
package{"openssl":ensure=>"1.0.1f"}
This should do the trick. (Hopefully.)
21 / 59
More nightmares
package{"openssl":ensure=>"1.0.1f"}
22 / 59
More nightmares
package{"openssl":ensure=>"1.0.1f"}
Package not found on the repos.
23 / 59
More nightmares
package{"openssl":ensure=>"1.0.1f"}
Package not found on the repos.
"Well, actually" we want an older version.
24 / 59
More nightmares
package{"openssl":ensure=>"1.0.1f"}
Package not found on the repos.
"Well, actually" we want an older version.
Package even less likely to be found on the repos.
25 / 59
More nightmares
package{"openssl":ensure=>"1.0.1f"}
Package not found on the repos.
"Well, actually" we want an older version.
Package even less likely to be found on the repos.
"Well, actually" we were using 0.9.8xxx.
When we requested 1.0.1g we upgraded the whole distro.
26 / 59
More nightmares
package{"openssl":ensure=>"1.0.1f"}
Package not found on the repos.
"Well, actually" we want an older version.
Package even less likely to be found on the repos.
"Well, actually" we were using 0.9.8xxx.
When we requested 1.0.1g we upgraded the whole distro.
(╯°□°)╯︵ ┻━┻)
27 / 59
With immutable servers
We still have the old server
Just put it back into service
(while we figure out the OpenSSL upgrade!)
Also works for any kind of upgrade
that needs to be rolled back
Alright, we have easy rollbacks.
But how does that help with drift?
28 / 59
"Trash your servers and burn your code"
(Chad Fowler)
Reprovision your servers regularly
(from scratch)
Ensures that you're always using recent packages
Any manual deviation gets fixed automatically
29 / 59
Improvement: golden image
Create a server from scratch
Apply deployment process
Snapshot this server (create an image)
(Optional: create a test server and validate it)
Create multiple identical servers from the image
Avoids uncertainties in the deployment process:
unreachable packages repositories etc.
Allows to keep (for cheap) past versions around.
30 / 59
Downsides
(and how to cope)
31 / 59
Problem: small changes are cumbersome
E.g. one line of CSS.
Before: manual change, validate, replicate
(a few minutes)
After: manual change, validate, ...
create new golden image from scratch
(one hour)
provision new servers from image
(a few minutes)
switch old/new servers
decommission old servers after a while
32 / 59
Solution: automation
All those operations have to happen
But everything after the "validate" step
should be automated
The clock time will still be 1+ hour
The user time will be a few minutes
(just like before)
Note: intermediary golden images can help
(provision from checkpoint instead of from scratch)
33 / 59
Problem: debugging is harder
E.g. troubleshoot network issues.
Before:
install tcpdump
fiddle with iptables
accumulate logs and packet captures locally
After:
install tcpdu-oops, the server was re-imaged
fiddle with ipta-oops, ...
logs and traces have to be shipped out
34 / 59
Solution 1: drift and self-destruct
Tag a given machine to prevent its "re-imaging"
Schedule it for self-destruct after e.g. 1 week
(shutdown+10000)
That machine is allowed to drift
(you can install your tools on it,
leave logs and traces locally...)
If you need more time, reschedule the self-destruct
35 / 59
Solution 1: drift and self-destruct
Tag a given machine to prevent its "re-imaging"
Schedule it for self-destruct after e.g. 1 week
(shutdown+10000)
That machine is allowed to drift
(you can install your tools on it,
leave logs and traces locally...)
If you need more time, reschedule the self-destruct
If you find yourself setting up a cron job to reschedule the self-
destruct, you're doing it wrong!
36 / 59
Solution 2: bundle the tools
Install tcpdumpand friends in the golden image
Enable traffic capture with feature switch
(Alternate solution: statistical sampling)
Automate shipping of logs and traces
It's more work in the beginning, but pays in the long run.
37 / 59
Problem: storing data
Databases and anything stateful!
Before: just store it locally
After: need to persist it somehow
38 / 59
Solution 1: not my problem
"Often you can pass the buck to a service which someone else
maintains, like Amazon's RDS database service."
(Kief Morris)
Easy!
But what if:
there is no such service
I can't use it for $REASONS?
39 / 59
Solution 2: state = files
All you need is a mechanism to store files externally.
NAS/SAN (on-prem)
EBS, EFS (AWS)
Ceph, Gluster... (anywhere)
But it's extra work, expensive, and/or slower.
40 / 59
Solution 3: ?
41 / 59
Solution 3: ?
SPOILER ALERT
42 / 59
Solution 3
43 / 59
Immutable
containers
44 / 59
Let's review our process
Create image:
from scratch
(can take an hour or more)
from checkpoint
(takes a few minutes, more complex)
Deploy it N times
(takes a few minutes)
How do we do that with containers?
45 / 59
Building container images
We get the best of both worlds:
from scratch
(clean rebuilds without side-effects)
incremental
(fast rebuilds when changes are minor)
Why and how?
container snapshots are cheap
(seconds versus minutes)
simple DSL to break down the build into steps
(each step = one command = one snapshot)
46 / 59
FROMdebian:jessie
MAINTAINERJessicaFrazelle<jess@docker.com>
#Installdependencies
RUNapt-getupdate&&apt-getinstall-y
build-essential
… 
--no-install-recommends
#Installnode
RUNcurl-sLhttps://deb.nodesource.com/setup|bash-
RUNapt-getinstall-ynodejs
#Cloneatom
RUNgitclonehttps://github.com/atom/atom/src
WORKDIR/src
RUNgitfetch&&gitcheckout
$(gitdescribe--tags
`gitrev-list--tags--max-count=1`)
RUNscript/build&&script/gruntinstall
#Autorunatom
CMD/usr/local/bin/atom--foreground
47 / 59
What happens during the first build?
FROMdebian
RUNapt-getxxx
COPY./src
RUN/src/build
Create a container from debianbase image
Execute apt-getxxxin this container, take a snapshot
Create a container from this snapshot
Copy source files into /src, take a snapshot
Create a container from this snapshot
Execute /src/buildin this container, take a snapshot
The final snapshot is our built image.
48 / 59
What happens during subsequent builds?
Before executing each step:
check if we already executed the same step before
(and have a snapshot of its result)
if we do, use the snapshot and continue
otherwise, execute the step normally
(and snapshot the result)
As a result, we zoom through the build process,
until we hit a step that has changed
The end result is the same as a full clean build,
but much faster
49 / 59
Demo
50 / 59
Running container images
On physical or virtual machines
Run multiple containers per machine
Upgrading is faster
(doesn't have to wait for IaaS VM to come up)
Can reuse local data (Docker concept: "volumes")
Solves the stateful service problem
51 / 59
Demo
52 / 59
Bonus
Containers can share:
directories (e.g.: logs)
network stack (e.g.: traffic analysis)
... and more!
Logging, backups, metrics collection, troubleshooting...
can be done from "sidekick" containers.
53 / 59
Demo
54 / 59
Other niceties
Containers filesystem can be made read-only
enforces immutability
exception for data volumes (with noexec)
easier security audit
Cheaper
consolidation
save a few ¢ or $ per server per deploy
(great if your IAAS bills by the hour)
55 / 59
Conclusions
56 / 59
Immutable containers
All the advantages of immutable servers
(avoid drift, reliable rollbacks...)
Build in seconds instead of minutes/hours
Faster, simpler deployment
Deal with stateful services
Bonus: cheaper, safer, cleaner
57 / 59
58 / 59
Thanks!
Questions?
@jpetazzo
@docker
59 / 59

More Related Content

PDF
Kubernetes Introduction
PDF
Introduction to Docker
PDF
Docker, Linux Containers (LXC), and security
PPTX
Docker, LinuX Container
PDF
Kubernetes
PPTX
Docker Security Overview
PDF
Asterisk High Availability Design Guide
PPTX
Gitlab CI/CD
Kubernetes Introduction
Introduction to Docker
Docker, Linux Containers (LXC), and security
Docker, LinuX Container
Kubernetes
Docker Security Overview
Asterisk High Availability Design Guide
Gitlab CI/CD

What's hot (20)

PPTX
Docker Container Security
PDF
Ansible - Introduction
PPTX
Kubernetes
PPTX
Docker 101 : Introduction to Docker and Containers
PDF
DevOps avec Ansible et Docker
PPTX
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
PDF
Docker Introduction
PDF
Docker in real life
PPTX
What is Docker
PPTX
K8s security best practices
PDF
OpenStack을 중심으로 한 오픈 소스 & 상용 하이브리드 클라우드
PDF
Docker and the Linux Kernel
PDF
Ansible tp
PDF
(발표자료) CentOS EOL에 따른 대응 OS 검토 및 적용 방안.pdf
PDF
Docker London: Container Security
PPTX
Getting started with Docker
PPTX
PrésentationCI_CD.pptx
PPTX
Introduction to Docker - 2017
PPTX
Docker: From Zero to Hero
PDF
Introduction to Docker storage, volume and image
Docker Container Security
Ansible - Introduction
Kubernetes
Docker 101 : Introduction to Docker and Containers
DevOps avec Ansible et Docker
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
Docker Introduction
Docker in real life
What is Docker
K8s security best practices
OpenStack을 중심으로 한 오픈 소스 & 상용 하이브리드 클라우드
Docker and the Linux Kernel
Ansible tp
(발표자료) CentOS EOL에 따른 대응 OS 검토 및 적용 방안.pdf
Docker London: Container Security
Getting started with Docker
PrésentationCI_CD.pptx
Introduction to Docker - 2017
Docker: From Zero to Hero
Introduction to Docker storage, volume and image
Ad

Viewers also liked (20)

PDF
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
PDF
Docker at Spotify
PDF
There is No Server: Immutable Infrastructure and Serverless Architecture
PDF
Deploy microservices in containers with Docker and friends - KCDC2015
PDF
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
PDF
Containers: from development to production at DevNation 2015
PDF
How to contribute to large open source projects like Docker (LinuxCon 2015)
PDF
Docker Non Technical Presentation
PDF
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
PDF
Docker: automation for the rest of us
PDF
Orchestration for the rest of us
PDF
From development environments to production deployments with Docker, Compose,...
PDF
Microservices. Microservices everywhere! (At OSCON 2015)
PDF
Immutable infrastructure:觀念與實作 (建議)
PDF
Making DevOps Secure with Docker on Solaris (Oracle Open World, with Jesse Bu...
PDF
Containers, docker, and security: state of the union (Bay Area Infracoders Me...
PDF
The Docker ecosystem and the future of application deployment
PDF
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
PDF
Docker : quels enjeux pour le stockage et réseau ? Paris Open Source Summit ...
PDF
Anatomy of a Container: Namespaces, cgroups & Some Filesystem Magic - LinuxCon
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Docker at Spotify
There is No Server: Immutable Infrastructure and Serverless Architecture
Deploy microservices in containers with Docker and friends - KCDC2015
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Containers: from development to production at DevNation 2015
How to contribute to large open source projects like Docker (LinuxCon 2015)
Docker Non Technical Presentation
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Docker: automation for the rest of us
Orchestration for the rest of us
From development environments to production deployments with Docker, Compose,...
Microservices. Microservices everywhere! (At OSCON 2015)
Immutable infrastructure:觀念與實作 (建議)
Making DevOps Secure with Docker on Solaris (Oracle Open World, with Jesse Bu...
Containers, docker, and security: state of the union (Bay Area Infracoders Me...
The Docker ecosystem and the future of application deployment
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
Docker : quels enjeux pour le stockage et réseau ? Paris Open Source Summit ...
Anatomy of a Container: Namespaces, cgroups & Some Filesystem Magic - LinuxCon
Ad

Similar to Immutable infrastructure with Docker and containers (GlueCon 2015) (20)

PDF
Easier, Better, Faster, Safer Deployment with Docker and Immutable Containers
PDF
Infrastructure as Code, Theory Crash Course
PDF
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
PDF
Docker Intro at the Google Developer Group and Google Cloud Platform Meet Up
PPTX
Containerize your Blackbox tests
PPT
PDF
Securing Containers, One Patch at a Time - Michael Crosby, Docker
PDF
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
PDF
What is this "docker"
PDF
Vagrant Workshop
PDF
Building a Gateway Server
KEY
Capistrano, Puppet, and Chef
PDF
Getting started with puppet and vagrant (1)
PPTX
A Fabric/Puppet Build/Deploy System
PDF
So. many. vulnerabilities. Why are containers such a mess and what to do abou...
PDF
Keep calm and vagrant up
PDF
OpenNebula 5.4 Hands-on Tutorial
PPT
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
PDF
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
PDF
Tiad - Docker: Automation for the rest of us
Easier, Better, Faster, Safer Deployment with Docker and Immutable Containers
Infrastructure as Code, Theory Crash Course
Puppet Camp Seattle 2014: Docker and Puppet: 1+1=3
Docker Intro at the Google Developer Group and Google Cloud Platform Meet Up
Containerize your Blackbox tests
Securing Containers, One Patch at a Time - Michael Crosby, Docker
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
What is this "docker"
Vagrant Workshop
Building a Gateway Server
Capistrano, Puppet, and Chef
Getting started with puppet and vagrant (1)
A Fabric/Puppet Build/Deploy System
So. many. vulnerabilities. Why are containers such a mess and what to do abou...
Keep calm and vagrant up
OpenNebula 5.4 Hands-on Tutorial
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
Tiad - Docker: Automation for the rest of us

More from Jérôme Petazzoni (13)

PDF
Use the Source or Join the Dark Side: differences between Docker Community an...
PDF
Introduction to Docker, December 2014 "Tour de France" Edition
PDF
Containers, Docker, and Microservices: the Terrific Trio
PDF
Containerization is more than the new Virtualization: enabling separation of ...
PDF
Pipework: Software-Defined Network for Containers and Docker
PDF
Docker Tips And Tricks at the Docker Beijing Meetup
PDF
Introduction to Docker at Glidewell Laboratories in Orange County
PDF
Docker en Production (Docker Paris)
PDF
Introduction to Docker at the Azure Meet-up in New York
PDF
Introduction to Docker and deployment and Azure
PDF
Killer Bugs From Outer Space
PDF
Docker, Linux Containers, and Security: Does It Add Up?
PDF
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Use the Source or Join the Dark Side: differences between Docker Community an...
Introduction to Docker, December 2014 "Tour de France" Edition
Containers, Docker, and Microservices: the Terrific Trio
Containerization is more than the new Virtualization: enabling separation of ...
Pipework: Software-Defined Network for Containers and Docker
Docker Tips And Tricks at the Docker Beijing Meetup
Introduction to Docker at Glidewell Laboratories in Orange County
Docker en Production (Docker Paris)
Introduction to Docker at the Azure Meet-up in New York
Introduction to Docker and deployment and Azure
Killer Bugs From Outer Space
Docker, Linux Containers, and Security: Does It Add Up?
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...

Recently uploaded (20)

PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
1. Introduction to Computer Programming.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Getting Started with Data Integration: FME Form 101
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Empathic Computing: Creating Shared Understanding
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
Accuracy of neural networks in brain wave diagnosis of schizophrenia
TLE Review Electricity (Electricity).pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
1. Introduction to Computer Programming.pptx
Spectral efficient network and resource selection model in 5G networks
Univ-Connecticut-ChatGPT-Presentaion.pdf
OMC Textile Division Presentation 2021.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Programs and apps: productivity, graphics, security and other tools
Group 1 Presentation -Planning and Decision Making .pptx
Getting Started with Data Integration: FME Form 101
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Network Security Unit 5.pdf for BCA BBA.
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
NewMind AI Weekly Chronicles - August'25-Week II
cloud_computing_Infrastucture_as_cloud_p
Empathic Computing: Creating Shared Understanding
A comparative analysis of optical character recognition models for extracting...
Diabetes mellitus diagnosis method based random forest with bat algorithm

Immutable infrastructure with Docker and containers (GlueCon 2015)