SlideShare a Scribd company logo
Matthias Lübken
Container Patterns
@luebken
“ Easily create lightweight, portable,
self-sufficient containers
from any application.”
“App Container (appc) is a well-specified and
community developed specification for
application containers. ”
nginx
Proxy
Rails
Frontend
A Go
Backend
A Node
Backend
An Application
Reuse
How does a good building block look like?
How do we assemble them?
Related Work
• 12factor.net apps
• Cloud-native application architectures:
Matt Stine Free Ebook
• Microservices
• Continuous Delivery
Container Patterns
•For designing “cloud” applications.
•Container runtime agnostic.
•Are there general applicable patterns?
•How would we describe them?
•What are concrete examples and best-practices?
Container Patterns
github.com/luebken/container-patterns
How does a good building block look like?
How do we assemble them?
“Module-Container”
A “Module-Container” is a well behaving
building block in the architecture of an
application.
A Module Container is
1. Linux process
2. API
3. Descriptive
4. Disposable
5. Immutable
6. Self-contained
7. Small
1.Linux Process
1. Linux Process
• React to signals
• Return exit codes
• Use standard streams
• Handle arguments
Examples: module-container.md#1-linux-process
2. API
2. API
• ENV variables
• Available ports
• Volume mounts
• Lifecycle hooks
Examples: module-container.md#2-api
3. Descriptive
3. Descriptive
• Use standard labels (e.g. proposal generic labels)
• url, summary, vcs-url …
• Use custom labels:
• api.ENV
• api.EXPOSE
• api.LINKS
Examples: module-container.md#3-descriptive
Container Patterns
POC github.com/luebken/container-api
4. Disposable
4. Disposable
• Don’t rely on a particular instance
• Be aware of shots at your cattle
• Be robust against sudden death
Examples: module-container.md#4-disposable
5. Immutable
5. Immutable
• Don’t change your container after build
• Strive or a dev/prod parity
Examples: module-container.md#5-immutable
6. Self-contained
6. Self-contained
• Add dependencies on build time
• Sensible defaults
Examples: module-container.md#6-self-contained
7. Small
7. Small
• Don’t use large base images
• Use the minimal footprint e.g. Alpine
Examples: module-container.md#6-small
Recap: A Module Container is
1. Linux process
2. API
3. Descriptive
4. Disposable
5. Immutable
6. Self-contained
7. Small
How does a good building block look like?
How do we assemble them?
nginx
Proxy
Rails
Frontend
A Go
Backend
A Node
Backend
nginx
Proxy
Rails
Frontend
A Go
Backend
A Node
Backend
Redis
Cache
Logging
Adapter
Service
Ambassador
A group of closely related containers. Deployed
as a single unit
and share namespaces.
A Node
Backend
Redis
Cache
Logging
Adapter
Service
Ambassador
Pattern: Sidecar / Sidekick
Enhance & extend the main container.
K8S: transparently. Netflix: platform features.
UDSA Node
Backend
MAIN CONTAINER
Redis
Cache
SIDECAR
Pod
A Node
Backend
Redis
Cache
Logging
Adapter
Service
Ambassador
Pattern: Adapter
Standardise and normalize output.
E.g. logging and metrics.
localhost or
A Node
Backend
MAIN CONTAINER
Logging
Adapter
ADAPTER
Pod
A Node
Backend
Redis
Cache
Logging
Adapter
Service
Ambassador
Proxy a local connection to the world:
Service Discovery, Client Side LB, Circuit Breaker
A Node
Backend
MAIN CONTAINER
Service
Discovery
AMBASSADOR
Pattern: Ambassador
localhost
(Pod)
Pattern: Container chains
Defined order of starting and stopping sidecar containers.
A Node
Backend
MAIN CONTAINER
Storage
Config
SIDECAR
Discovery
SIDECAR
Network
Config
SIDECAR
(Pod)
Summary: Container Patterns QCON 08.03.2016
Module container
1. Linux process
2. API
3. Descriptive
4. Disposable
5. Immutable
6. Self-contained
7. Small
Composite
• Sidecar
• Adapter
• Ambassador
• Chains
How does a good
building block look
like?
And how would you
assemble them?
github.com/luebken/container-patterns @luebken
matthias@luebken.com
Dankeschön.
@luebken
Credits
• https://www.flickr.com/photos/skynoir/8241460998 (Cover image)
• https://www.flickr.com/photos/amlz/8664728590 (Lego)
• https://www.flickr.com/photos/guidedbycthulhu/6810361241 (Socket)
• https://www.flickr.com/photos/seektan/2074853585/ (Label)
• https://www.flickr.com/photos/gullevek/2122873934 (Trash)
• https://www.flickr.com/photos/grantmac/4852826923 (Lock)
• https://www.flickr.com/photos/mhirano/13236048424 (Hand)

More Related Content

PPTX
Kubernetes workshop
PDF
Kubernetes: Reducing Infrastructure Cost & Complexity
PDF
Implementing Observability for Kubernetes.pdf
PPTX
About DevOps in simple steps
PPTX
K8s in 3h - Kubernetes Fundamentals Training
PDF
Observability
PDF
Why Microservice
PDF
CI/CD (DevOps) 101
Kubernetes workshop
Kubernetes: Reducing Infrastructure Cost & Complexity
Implementing Observability for Kubernetes.pdf
About DevOps in simple steps
K8s in 3h - Kubernetes Fundamentals Training
Observability
Why Microservice
CI/CD (DevOps) 101

What's hot (20)

PDF
A GitOps Kubernetes Native CICD Solution with Argo Events, Workflows, and CD
PPTX
How to Move from Monitoring to Observability, On-Premises and in a Multi-Clou...
PDF
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
PDF
DevOps
PPTX
Docker Kubernetes Istio
PPTX
Adopting OpenTelemetry
PDF
Monitoring As a Service
PDF
Autoscaling Kubernetes
PDF
Deploy Application on Kubernetes
PDF
Observability
PPSX
Microservices Docker Kubernetes Istio Kanban DevOps SRE
PDF
Ansible
PDF
Testing Persistent Storage Performance in Kubernetes with Sherlock
PPSX
Docker Kubernetes Istio
PPTX
Log analysis using Logstash,ElasticSearch and Kibana
PDF
Introduction to CICD
PDF
Deploying your first application with Kubernetes
PDF
Designing a complete ci cd pipeline using argo events, workflow and cd products
PDF
GitOps and ArgoCD
PPTX
Microservices Architecture & Testing Strategies
A GitOps Kubernetes Native CICD Solution with Argo Events, Workflows, and CD
How to Move from Monitoring to Observability, On-Premises and in a Multi-Clou...
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
DevOps
Docker Kubernetes Istio
Adopting OpenTelemetry
Monitoring As a Service
Autoscaling Kubernetes
Deploy Application on Kubernetes
Observability
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Ansible
Testing Persistent Storage Performance in Kubernetes with Sherlock
Docker Kubernetes Istio
Log analysis using Logstash,ElasticSearch and Kibana
Introduction to CICD
Deploying your first application with Kubernetes
Designing a complete ci cd pipeline using argo events, workflow and cd products
GitOps and ArgoCD
Microservices Architecture & Testing Strategies
Ad

Viewers also liked (13)

PDF
Highly scalable caching service on cloud - Redis
PPTX
The SOLID Principles Illustrated by Design Patterns
ODP
Liquibase & Flyway @ Baltic DevOps
PDF
Containers, Clusters and Kubernetes - Brendan Burns - Defrag 2014
PDF
An introduction to AWS Direct Connect
PPTX
Business Continuity & Disaster Recovery with Microsoft Azure
PDF
DockerCon SF 2015: The Distributed System Toolkit
PPTX
Containers: Life Beyond Microservices? by Sushil Kumar, Robin Systems
PDF
Shipping Applications to Production in Containers with Docker
PPT
20. Object-Oriented Programming Fundamental Principles
PPT
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
PDF
Microservices, Containers, Docker and a Cloud-Native Architecture in the Midd...
PPT
Function Oriented Design
Highly scalable caching service on cloud - Redis
The SOLID Principles Illustrated by Design Patterns
Liquibase & Flyway @ Baltic DevOps
Containers, Clusters and Kubernetes - Brendan Burns - Defrag 2014
An introduction to AWS Direct Connect
Business Continuity & Disaster Recovery with Microsoft Azure
DockerCon SF 2015: The Distributed System Toolkit
Containers: Life Beyond Microservices? by Sushil Kumar, Robin Systems
Shipping Applications to Production in Containers with Docker
20. Object-Oriented Programming Fundamental Principles
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Microservices, Containers, Docker and a Cloud-Native Architecture in the Midd...
Function Oriented Design
Ad

Similar to Container Patterns (20)

PDF
Patterns in a Containerized World (Matthias Luebken Technology Stream)
PDF
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
PDF
Docker what - Frank Maounis
PDF
Docker in Production: How RightScale Delivers Cloud Applications
PDF
The ABC of Docker: The Absolute Best Compendium of Docker
PDF
Docker dev ops for cd meetup 12-14
PPTX
The challenge of application distribution - Introduction to Docker (2014 dec ...
PDF
Docker's Jérôme Petazzoni: Best Practices in Dev to Production Parity for Con...
PDF
The Kubernetes Effect
PDF
Rackspace::Solve NYC - The Future of Applications with Ken Cochrane, Engineer...
PPTX
Docker-N-Beyond
PPTX
DockerDay2015: Keynote
PPTX
State of the Container Ecosystem
PDF
Docker introduction
PPTX
Microservices
PDF
Microservices Docker @Bonn Agile
PPTX
Why Docker
PPTX
Microservices and containers for the unitiated
PPTX
Docker, Containers and the Future of Application Delivery
PDF
Containers and Nutanix - Acropolis Container Services
Patterns in a Containerized World (Matthias Luebken Technology Stream)
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
Docker what - Frank Maounis
Docker in Production: How RightScale Delivers Cloud Applications
The ABC of Docker: The Absolute Best Compendium of Docker
Docker dev ops for cd meetup 12-14
The challenge of application distribution - Introduction to Docker (2014 dec ...
Docker's Jérôme Petazzoni: Best Practices in Dev to Production Parity for Con...
The Kubernetes Effect
Rackspace::Solve NYC - The Future of Applications with Ken Cochrane, Engineer...
Docker-N-Beyond
DockerDay2015: Keynote
State of the Container Ecosystem
Docker introduction
Microservices
Microservices Docker @Bonn Agile
Why Docker
Microservices and containers for the unitiated
Docker, Containers and the Future of Application Delivery
Containers and Nutanix - Acropolis Container Services

More from Matthias Luebken (14)

PDF
Who needs containers in a serverless world
PDF
Who needs containers in a serverless world
PDF
Eine Einführung in Docker
PDF
How to scale product development when you no longer fit in one room
PDF
How to scale product development when you no longer fit in one room
PDF
Docker Introduction – @ Agile Bonn
PDF
“Und wie war ich so?”
Feedback in Unternehmen
PDF
Home- (office) ?
PDF
Staying Startup
PDF
Talk: Staying Startup at Interactive-Cologne
PDF
Verbessertes Feedback durch Peerreview
PDF
Mobile WebApps
PDF
Mobile Webapps Entwicklung
PDF
Mobile Webapps Motivation
Who needs containers in a serverless world
Who needs containers in a serverless world
Eine Einführung in Docker
How to scale product development when you no longer fit in one room
How to scale product development when you no longer fit in one room
Docker Introduction – @ Agile Bonn
“Und wie war ich so?”
Feedback in Unternehmen
Home- (office) ?
Staying Startup
Talk: Staying Startup at Interactive-Cologne
Verbessertes Feedback durch Peerreview
Mobile WebApps
Mobile Webapps Entwicklung
Mobile Webapps Motivation

Recently uploaded (20)

PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
Lecture Notes Electrical Wiring System Components
PDF
ETO & MEO Certificate of Competency Questions and Answers
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
CH1 Production IntroductoryConcepts.pptx
PPT
Drone Technology Electronics components_1
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPT
Project quality management in manufacturing
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
web development for engineering and engineering
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Geodesy 1.pptx...............................................
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Structs to JSON How Go Powers REST APIs.pdf
Lecture Notes Electrical Wiring System Components
ETO & MEO Certificate of Competency Questions and Answers
Lesson 3_Tessellation.pptx finite Mathematics
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
CH1 Production IntroductoryConcepts.pptx
Drone Technology Electronics components_1
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Project quality management in manufacturing
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
web development for engineering and engineering
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Geodesy 1.pptx...............................................

Container Patterns

Editor's Notes

  • #3: About me developer: OSGi, {team, group, department} lead product guy Slides and code examples will be available online
  • #4: Docker introduced the term “application container”. Containers are not just a lightweight VM.
  • #5: Others have incorporated that term like the appc standard.
  • #6: An application usually consists of multiple containers. How would I design my containers that they well behave in my application?
  • #7: Let’s take a close look the building blocks. What color, size? Kind of connectors? Reasons for having multiple building blocks.
  • #8: These are the questions we should ask ourselves when designing and developing applications with containers.
  • #10: There is a lot related work / prior art: Modules, Distributed systems, Continuos integration See especially cloud native / paas experience.
  • #17: We need to remember that a container is foremost a Linux process. Which is separated by namespaces and controlled by cgroups.
  • #18: React to signals Use the `exec` form Catch signals: SIGINT: Interrupt by Ctrl-C, SIGTERM: Process termination by schedular like `docker stop` Return exit codes: `0` for successful termination, `>0` for a failure Handle arguments: Use conventions like POSIX or a library Use standard streams Use standard out for logging let the infrastructure (or sidecar) handle the forwarding
  • #20: env usage was proposed by 12Factor easy to change between deploys, no danger go checking in set default in image and let user overwrite with `docker -e` use simple tools like `envtpl` https://github.com/andreasjansson/envtpl ports: use `EXPOSE` they will show up in `docker ps` and `docker inspect` can be enforced with `iptables = true` && `icc = false volume mounts different patterns depend on this like data-container hooks sometimes the container lifecycle is not enough. e.g. database init kubernetes and runc have them. you can build them with docker events
  • #22: TODO: schema for labels
  • #26: start with `docker — rm` many reasons for a container instance going away Rescheduling because of limit or bad resources Down-scaling Errors within the container Migration to new hardware / locality of services Be robust against sudden death. Minimal setup Counter argument: OPs argues they want to keep as much as possible after a crash TODO what does kubernetes do with logs Pets vs. Cattle: Treat your container as part of a cattle. You number them and when get sick you shoot them Note: Most argued slide so far.
  • #28: dev / prod parity extract runtime state in volumes Anti-pattern: `docker exec`
  • #30: E.g. Build Uber-Jar and include webserver Generate dynamic config files on the fly.: confd
  • #32: Build from scratch Use small base-image busybox, alpine Reuse custom base image Anti-Pattern: VM Container
  • #35: You can hook up containers just as ordinary services. Let’s look into something special with containers.
  • #37: Hands up: Who knows Docker? Who knows Pods? Pods: Kubernetes and rkt. (Docker working on something?) Share all available namespaces Network, IPC, UTS (hostname), Volumes, PID The pod as a whole can be limited or the individual container.
  • #39: A general pattern about adding functionality for the main container Netflix: coined the term for adding platform features Burns: uses examples with transparent sidecars
  • #41: Special purpose side-car Full-fill a contract to the outside e.g.Present a consistent interface for a monitoring system
  • #43: All connections are proxied by the Ambassadors Resolves endpoint and establish connections More logic like client-side load balancing circuit breakers Pods optional: depend on the implementation Coined by Docker implemented using Docker links Next brought to a wider audience by CoreOS using etcd Nowadays seen many times using Consul
  • #44: starting all containers at once will end in chaos (e.g. storage not being ready for example) some things have to wait on each other (e.g. discovery needs network access) shutdowns also have order (e.g. de-register a consul node before the node backend shuts down & finish open requests) an error in one of the process will result in a restart of the whole chain Implementation Basically we are talking about requirements for an init process with systemd with attributes e.g. “Requires=” and “After=” But also custom implementations (e.g. a Golang binary taking care of this) // Wandering how this could be implemented with Kubernetes The example: Storage: ensure that the volume data that the container requires is available Network: setup network for custom networks like weave or shared network between user pods Main Container: Well, thats your business service, man! Discovery: Announce the world that your business is running! So other services can use it. Note: Pods are fro many use-cases optional. Most containers shown here do need to run as a group (start together, die together), but not necessarily run in the same cgroups/namespaces etc.