SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
Lessons Learned
from Running
Docker in Production
Nicholas Dille, Docker Captain & CDM MVP
Nicholas Dille
Ehemann, Vater, Geek, Autor
Microsoft MVP seit 2010
Docker Captain seit 2017
DevOps Engineer @ Haufe-Lexware
http://dille.name/blog
@NicholasDille
Run
Docker Tools
Host
docker-compose.yml
Dockerfile Image Image
Container
Registry
Container
Push
Pull
ImageBuild
Do not use latest
Latest is like buying a pig in a poke
ubuntu:latest = ubuntu:xenial until new LTS
ubuntu:xenial = ubuntu:xenial-20180123 until new monthly patch
Latest breaks repeatability
Derive from specific version
Update regularly, fail early
Do not use latest
Dockerfile
FROM ubuntu
#...
Dockerfile
FROM nginx
#...
Dockerfile
FROM ubuntu:xenial-20180123
#...
Dockerfile
FROM nginx:1.12.1
#...
Derive from code
Using community images is also like buying a pig in a poke
h1kkan/jenkins-docker is has lots of useful stuff
Community images may not receive updates
Community images may follow undesirable paths
Fork Dockerfile and build yourself
Plan for PID 1
Even containerized services want to exit gracefully
Only containerized PID 1 received signals
Several processed require an init process
Choices include supervisor, dumb-init, tini
Use exec when starting from scripts
Isolate in sidekicks
Plan for PID 1
Dockerfile
FROM ubuntu:xenial-20180123
RUN apt update 
&& apt install -y nginx
ADD entrypoint.sh /
ENTRYPOINT /entrypoint.sh
entrypoint.sh
#!/bin/bash
#...
exec nginx -g daemon=off;
Plan for PID 1
Dockerfile
FROM ubuntu:xenial-20180123
RUN apt update 
&& apt install -y 
nginx 
supervisor
ADD nginx.conf /etc/supervisor/conf.d/
ENTRYPOINT supervisord
nginx.conf
[program:nginx]
command=nginx -g daemon=off;
Use microlabeling
Mark images with information about origin
Easily find corresponding code
Use image annotations by the OCI
Deprecated: https://label-schema.org
Use microlabeling
Dockerfile
FROM ubuntu:xenial-20180123
LABEL 
org.opencontainers.image.created=“2018-01-31T20:00:00Z+01:00“ 
org.opencontainers.image.authors=“nicholas@dille.name“ 
org.opencontainers.image.source=“https://github.com/nicholasdille/docker“ 
org.opencontainers.image.revision=“566a5e0“ 
org.opencontainers.image.vendor=“Nicholas Dille“
#...
Parameterize
Hardcoded values increase maintenance
Separate environmental information
Use ENV in Dockerfile
Use environment in docker-compose.yml
Parameterize
Dockerfile
FROM ubuntu:xenial-20180123
RUN apt update 
&& apt -y install 
nginx=1.10.3*
Dockerfile
FROM ubuntu:xenial-20180123
ENV NGINX_VERSION=1.10.3
RUN apt update 
&& apt -y install 
nginx=${NGINX_VERSION}*
Parameterize
docker-compose.yml
version: ‘2.0‘
services:
db:
image: postgres-${POSTGRES_VERSION}
environment:
POSTGRES_PASSWORD: ${POSTGRES_ROOT_PASSWORD}
web:
image: nginx-${NGINX_VERSION}
Readability beats size
Myth: More layers reduce access time
My own tests prove otherwise
Layers improve performance on pull (parallel downloads)
One layer per installed tool
Separate functionality into chains of images
dind  dind-gocd-agent
 linux-agent  linux-agent-gocd
 linux-agent-jenkins
Tips and tricks
Building behind a proxy
docker build 
--build-arg http_proxy 
--build-arg https_proxy 
--build-arg no_proxy
.
Running behind a proxy
docker run -it 
--env http_proxy 
--env https_proxy 
--env no_proxy 
ubuntu:xenial-20180123
Implicit pull on build
docker build --pull .
Automatic cleanup
docker run -it --rm ubuntu:xenial
Derive dynamically
ARG VERSION=xenial-20180123
FROM ubuntu:${VERSION}
Learn your own lessons
Do my lessons apply to you?
Automate
Do CI/CD
Containers are just one option
Link to code
https://github.com/nicholasdille/Sessions/tree/master/2018-01-
31%20Docker%20%40%20Devsmeetup

Más contenido relacionado

La actualidad más candente

Docker Plugin for Heat
Docker Plugin for HeatDocker Plugin for Heat
Docker Plugin for Heat
Docker, Inc.
 
Deploying Windows Containers with Draft, Helm and Kubernetes
Deploying Windows Containers with Draft, Helm and KubernetesDeploying Windows Containers with Draft, Helm and Kubernetes
Deploying Windows Containers with Draft, Helm and Kubernetes
Jessica Deen
 

La actualidad más candente (20)

Bauen und Verteilen von Multi-Arch Docker Images für Linux und Windows
Bauen und Verteilen von Multi-Arch Docker Images für Linux und WindowsBauen und Verteilen von Multi-Arch Docker Images für Linux und Windows
Bauen und Verteilen von Multi-Arch Docker Images für Linux und Windows
 
Docker on Windows and Linux - Red Shirt Dev Tour
Docker on Windows and Linux - Red Shirt Dev TourDocker on Windows and Linux - Red Shirt Dev Tour
Docker on Windows and Linux - Red Shirt Dev Tour
 
Docker - A container full of Chocolatey
Docker - A container full of ChocolateyDocker - A container full of Chocolatey
Docker - A container full of Chocolatey
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandCI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
 
How To Make A Framework Plugin That Does Not Suck
How To Make A Framework Plugin That Does Not SuckHow To Make A Framework Plugin That Does Not Suck
How To Make A Framework Plugin That Does Not Suck
 
Debugging Go in Kubernetes
Debugging Go in KubernetesDebugging Go in Kubernetes
Debugging Go in Kubernetes
 
How to Use Mirroring and Caching to Optimize your Container Registry
How to Use Mirroring and Caching to Optimize your Container RegistryHow to Use Mirroring and Caching to Optimize your Container Registry
How to Use Mirroring and Caching to Optimize your Container Registry
 
Google ko: fast Kubernetes microservice development in Go - Sangam Biradar, E...
Google ko: fast Kubernetes microservice development in Go - Sangam Biradar, E...Google ko: fast Kubernetes microservice development in Go - Sangam Biradar, E...
Google ko: fast Kubernetes microservice development in Go - Sangam Biradar, E...
 
Docker Plugin for Heat
Docker Plugin for HeatDocker Plugin for Heat
Docker Plugin for Heat
 
Setup a Dev environment that feels like $HOME on Windows 10
Setup a Dev environment that feels like $HOME on Windows 10Setup a Dev environment that feels like $HOME on Windows 10
Setup a Dev environment that feels like $HOME on Windows 10
 
Docker Tooling for Eclipse
Docker Tooling for EclipseDocker Tooling for Eclipse
Docker Tooling for Eclipse
 
Cloud Native Okteto Cloud
Cloud Native Okteto Cloud Cloud Native Okteto Cloud
Cloud Native Okteto Cloud
 
#dddsw - Modernizing .NET Apps with Docker
#dddsw - Modernizing .NET Apps with Docker#dddsw - Modernizing .NET Apps with Docker
#dddsw - Modernizing .NET Apps with Docker
 
Neo4j on Azure Step by Step
Neo4j on Azure Step by StepNeo4j on Azure Step by Step
Neo4j on Azure Step by Step
 
#SDD2017 - Modernizing .NET Apps with Docker
#SDD2017 - Modernizing .NET Apps with Docker#SDD2017 - Modernizing .NET Apps with Docker
#SDD2017 - Modernizing .NET Apps with Docker
 
CI/CD Pipeline with Docker
CI/CD Pipeline with DockerCI/CD Pipeline with Docker
CI/CD Pipeline with Docker
 
Introduction to dockerfile, SF Peninsula Software Development Meetup @Guidewire
Introduction to dockerfile, SF Peninsula Software Development Meetup @Guidewire Introduction to dockerfile, SF Peninsula Software Development Meetup @Guidewire
Introduction to dockerfile, SF Peninsula Software Development Meetup @Guidewire
 
Neo4j 2.0.1 Windows Azure VM Release
Neo4j 2.0.1 Windows Azure VM ReleaseNeo4j 2.0.1 Windows Azure VM Release
Neo4j 2.0.1 Windows Azure VM Release
 
Zalenium - SeleniumConf Austin 2017
Zalenium - SeleniumConf Austin 2017Zalenium - SeleniumConf Austin 2017
Zalenium - SeleniumConf Austin 2017
 
Deploying Windows Containers with Draft, Helm and Kubernetes
Deploying Windows Containers with Draft, Helm and KubernetesDeploying Windows Containers with Draft, Helm and Kubernetes
Deploying Windows Containers with Draft, Helm and Kubernetes
 

Similar a Lessons Learned from running Docker in production

Similar a Lessons Learned from running Docker in production (20)

How to Improve Your Image Builds Using Advance Docker Build
How to Improve Your Image Builds Using Advance Docker BuildHow to Improve Your Image Builds Using Advance Docker Build
How to Improve Your Image Builds Using Advance Docker Build
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
 
2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.com2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.com
 
DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
 
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
 
DockerCon EU 2015: Trading Bitcoin with Docker
DockerCon EU 2015: Trading Bitcoin with DockerDockerCon EU 2015: Trading Bitcoin with Docker
DockerCon EU 2015: Trading Bitcoin with Docker
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
 
Docker - What it is and how to get started?
Docker - What it is and how to get started?Docker - What it is and how to get started?
Docker - What it is and how to get started?
 
Using docker to develop NAS applications
Using docker to develop NAS applicationsUsing docker to develop NAS applications
Using docker to develop NAS applications
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
 
Cloud native buildpacks-cncf
Cloud native buildpacks-cncfCloud native buildpacks-cncf
Cloud native buildpacks-cncf
 
Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
 
SDLC Using Docker for Fun and Profit
SDLC Using Docker for Fun and ProfitSDLC Using Docker for Fun and Profit
SDLC Using Docker for Fun and Profit
 
Mihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate EverythingMihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate Everything
 
Docker for .NET Developers - Michele Leroux Bustamante, Solliance
Docker for .NET Developers - Michele Leroux Bustamante, SollianceDocker for .NET Developers - Michele Leroux Bustamante, Solliance
Docker for .NET Developers - Michele Leroux Bustamante, Solliance
 
Deliver Python Apps with Docker
Deliver Python Apps with DockerDeliver Python Apps with Docker
Deliver Python Apps with Docker
 
Docker e git lab
Docker e git labDocker e git lab
Docker e git lab
 
Dockerizing Ruby Applications - The Best Practices
Dockerizing Ruby Applications - The Best PracticesDockerizing Ruby Applications - The Best Practices
Dockerizing Ruby Applications - The Best Practices
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 

Lessons Learned from running Docker in production

  • 1. Lessons Learned from Running Docker in Production Nicholas Dille, Docker Captain & CDM MVP
  • 2. Nicholas Dille Ehemann, Vater, Geek, Autor Microsoft MVP seit 2010 Docker Captain seit 2017 DevOps Engineer @ Haufe-Lexware http://dille.name/blog @NicholasDille
  • 3. Run Docker Tools Host docker-compose.yml Dockerfile Image Image Container Registry Container Push Pull ImageBuild
  • 4. Do not use latest Latest is like buying a pig in a poke ubuntu:latest = ubuntu:xenial until new LTS ubuntu:xenial = ubuntu:xenial-20180123 until new monthly patch Latest breaks repeatability Derive from specific version Update regularly, fail early
  • 5. Do not use latest Dockerfile FROM ubuntu #... Dockerfile FROM nginx #... Dockerfile FROM ubuntu:xenial-20180123 #... Dockerfile FROM nginx:1.12.1 #...
  • 6. Derive from code Using community images is also like buying a pig in a poke h1kkan/jenkins-docker is has lots of useful stuff Community images may not receive updates Community images may follow undesirable paths Fork Dockerfile and build yourself
  • 7. Plan for PID 1 Even containerized services want to exit gracefully Only containerized PID 1 received signals Several processed require an init process Choices include supervisor, dumb-init, tini Use exec when starting from scripts Isolate in sidekicks
  • 8. Plan for PID 1 Dockerfile FROM ubuntu:xenial-20180123 RUN apt update && apt install -y nginx ADD entrypoint.sh / ENTRYPOINT /entrypoint.sh entrypoint.sh #!/bin/bash #... exec nginx -g daemon=off;
  • 9. Plan for PID 1 Dockerfile FROM ubuntu:xenial-20180123 RUN apt update && apt install -y nginx supervisor ADD nginx.conf /etc/supervisor/conf.d/ ENTRYPOINT supervisord nginx.conf [program:nginx] command=nginx -g daemon=off;
  • 10. Use microlabeling Mark images with information about origin Easily find corresponding code Use image annotations by the OCI Deprecated: https://label-schema.org
  • 11. Use microlabeling Dockerfile FROM ubuntu:xenial-20180123 LABEL org.opencontainers.image.created=“2018-01-31T20:00:00Z+01:00“ org.opencontainers.image.authors=“nicholas@dille.name“ org.opencontainers.image.source=“https://github.com/nicholasdille/docker“ org.opencontainers.image.revision=“566a5e0“ org.opencontainers.image.vendor=“Nicholas Dille“ #...
  • 12. Parameterize Hardcoded values increase maintenance Separate environmental information Use ENV in Dockerfile Use environment in docker-compose.yml
  • 13. Parameterize Dockerfile FROM ubuntu:xenial-20180123 RUN apt update && apt -y install nginx=1.10.3* Dockerfile FROM ubuntu:xenial-20180123 ENV NGINX_VERSION=1.10.3 RUN apt update && apt -y install nginx=${NGINX_VERSION}*
  • 15. Readability beats size Myth: More layers reduce access time My own tests prove otherwise Layers improve performance on pull (parallel downloads) One layer per installed tool Separate functionality into chains of images dind  dind-gocd-agent  linux-agent  linux-agent-gocd  linux-agent-jenkins
  • 16. Tips and tricks Building behind a proxy docker build --build-arg http_proxy --build-arg https_proxy --build-arg no_proxy . Running behind a proxy docker run -it --env http_proxy --env https_proxy --env no_proxy ubuntu:xenial-20180123 Implicit pull on build docker build --pull . Automatic cleanup docker run -it --rm ubuntu:xenial Derive dynamically ARG VERSION=xenial-20180123 FROM ubuntu:${VERSION}
  • 17. Learn your own lessons Do my lessons apply to you? Automate Do CI/CD Containers are just one option Link to code https://github.com/nicholasdille/Sessions/tree/master/2018-01- 31%20Docker%20%40%20Devsmeetup