SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
Docker Best Practices
Development and
Production
1 / 44
Why should you be serious
about using it
2 / 44
development:
3 / 44
docker-compose
4 / 44
version: "3"
services:
app:
build: ./app
5 / 44
bring up in 1 command
6 / 44
run as another user
7 / 44
image size
8 / 44
multi-stage builds
9 / 44
FROM gcr.io/connectedcars-staging/connectedcars-node:9.3 as builder
ARG GITHUB_AT
WORKDIR /app
RUN apt-get update && apt-get install -y mysql-client
ADD . /app
RUN yarn global add node-gyp
RUN yarn
ENV NODE_ENV production
RUN npm run compile
RUN rm -rf node_modules && yarn
FROM gcr.io/connectedcars-staging/connectedcars-node-production:9.3
ENV NODE_ENV production
WORKDIR /app
EXPOSE 9000
COPY --from=builder /app .
CMD npm run production
10 / 44
use official images
11 / 44
create your own base
images
12 / 44
don't use latest, use git sha
images are mutable
13 / 44
Continues Integration
14 / 44
Google Cloud Builder
15 / 44
Google Container Registry
16 / 44
overlay network
multiple networks
17 / 44
version: "3"
services:
proxy:
build: ./proxy
networks:
- frontend
app:
build: ./app
networks:
- frontend
- backend
db:
image: postgres
networks:
- backend
networks:
frontend:
backend:
18 / 44
docker volumes
19 / 44
version: "3"
services:
db:
image: db
volumes:
- data-volume:/var/lib/db
backup:
image: backup-service
volumes:
- data-volume:/var/lib/backup/data
volumes:
data-volume:
20 / 44
service discovery
21 / 44
version: "3"
services:
app:
build: ./app
db:
image: db
22 / 44
limits?
23 / 44
version: '3'
services:
redis:
image: myapp
deploy:
resources:
limits:
cpus: '0.50'
memory: 500M
reservations:
cpus: '0.25'
memory: 200M
24 / 44
Kubernetes for
development?
25 / 44
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: kevin-myapp
spec:
selector:
matchLabels:
app: kevin-myapp
replicas: 2 # tells deployment to run 2 pods matching the template
template: # create pods using pod definition in this template
metadata:
labels:
app: kevin-myapp
spec:
containers:
- name: kevin-myapp
image: gcr.io/dd-decaf-cfbf6/kevin-myapp:latest
ports:
- containerPort: 8000
26 / 44
production:
27 / 44
secrets should be files
28 / 44
docker run -v $(pwd)/secrets/db.json:/secrets/db.json myapp
29 / 44
run as read-only
30 / 44
docker run -d -p 80:80 --read-only nginx
31 / 44
seccomp / apparmour
32 / 44
33 / 44
gvisor
Google Container Runtime Sandbox
34 / 44
35 / 44
36 / 44
37 / 44
Jessie Franzelle
https://blog.jessfraz.com/post/containers-security-and-echo-chambers/
38 / 44
$ docker run --rm 
-it 
--security-opt seccomp=/path/to/seccomp/profile.json 
hello-world
39 / 44
demo seccomp
https://docs.docker.com/engine/security/seccomp/#significant-syscalls-blocked-by-the-
default-profile
https://raw.githubusercontent.com/moby/moby/master/profiles/seccomp/default.json
40 / 44
Connected Cars
41 / 44
Startup, Serverless...
42 / 44
Summary
bring up in 1 command
read-only
secrets as files
seccomp is power full
43 / 44
kevin.simper@gmail.com
@kevinsimper
44 / 44

Weitere Àhnliche Inhalte

Was ist angesagt?

Jenkins X Hands-on - automated CI/CD solution for cloud native applications o...
Jenkins X Hands-on - automated CI/CD solution for cloud native applications o...Jenkins X Hands-on - automated CI/CD solution for cloud native applications o...
Jenkins X Hands-on - automated CI/CD solution for cloud native applications o...
Ted Won
 
2013-03-07 indie developer toolkit
2013-03-07 indie developer toolkit2013-03-07 indie developer toolkit
2013-03-07 indie developer toolkit
CocoaHeads Tricity
 

Was ist angesagt? (20)

Introduction to Jenkins X
Introduction to Jenkins XIntroduction to Jenkins X
Introduction to Jenkins X
 
Capedwarf
CapedwarfCapedwarf
Capedwarf
 
Jenkins X Hands-on - automated CI/CD solution for cloud native applications o...
Jenkins X Hands-on - automated CI/CD solution for cloud native applications o...Jenkins X Hands-on - automated CI/CD solution for cloud native applications o...
Jenkins X Hands-on - automated CI/CD solution for cloud native applications o...
 
Happy Helming With Okteto
Happy Helming With OktetoHappy Helming With Okteto
Happy Helming With Okteto
 
New Features Webinar-April
New Features Webinar-AprilNew Features Webinar-April
New Features Webinar-April
 
Front matter: Next Level Front End Deployments on OpenShift
Front matter: Next Level Front End Deployments on OpenShiftFront matter: Next Level Front End Deployments on OpenShift
Front matter: Next Level Front End Deployments on OpenShift
 
Hot deployments with distillery
Hot deployments with distilleryHot deployments with distillery
Hot deployments with distillery
 
Đ—ĐŸĐŸĐżĐ°Ń€Đș React-у
Đ—ĐŸĐŸĐżĐ°Ń€Đș React-ŃƒĐ—ĐŸĐŸĐżĐ°Ń€Đș React-у
Đ—ĐŸĐŸĐżĐ°Ń€Đș React-у
 
React native development with expo
React native development with expoReact native development with expo
React native development with expo
 
OSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and Docker
OSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and DockerOSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and Docker
OSCONF - April 2021 - Run GitHub Actions Locally with nektos/act and Docker
 
Seamless Continuous Deployment Using Docker Containers
Seamless Continuous Deployment Using Docker ContainersSeamless Continuous Deployment Using Docker Containers
Seamless Continuous Deployment Using Docker Containers
 
2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new
 
Introduction of cloud native CI/CD on kubernetes
Introduction of cloud native CI/CD on kubernetesIntroduction of cloud native CI/CD on kubernetes
Introduction of cloud native CI/CD on kubernetes
 
Angboard
AngboardAngboard
Angboard
 
Microsoft azure pipeline + Docker + Amazon s3 + Jekyll + github
Microsoft azure pipeline + Docker + Amazon s3 + Jekyll + githubMicrosoft azure pipeline + Docker + Amazon s3 + Jekyll + github
Microsoft azure pipeline + Docker + Amazon s3 + Jekyll + github
 
Ultimate Productivity Tools
Ultimate Productivity ToolsUltimate Productivity Tools
Ultimate Productivity Tools
 
2013-03-07 indie developer toolkit
2013-03-07 indie developer toolkit2013-03-07 indie developer toolkit
2013-03-07 indie developer toolkit
 
Deploy With Codefresh to Kubernetes in 3 steps
Deploy With Codefresh to Kubernetes in 3 stepsDeploy With Codefresh to Kubernetes in 3 steps
Deploy With Codefresh to Kubernetes in 3 steps
 
Gitflow Workflow
Gitflow WorkflowGitflow Workflow
Gitflow Workflow
 
DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...
DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...
DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...
 

Ähnlich wie Docker Best Practices in development and Production

Ähnlich wie Docker Best Practices in development and Production (20)

Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
 
Docker dev, test & production (afas)
Docker  dev, test & production (afas)Docker  dev, test & production (afas)
Docker dev, test & production (afas)
 
Using Docker For Development
Using Docker For DevelopmentUsing Docker For Development
Using Docker For Development
 
DCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best Practices
 
From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016
 
DevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux ContainersDevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux Containers
 
Gitlab ci e kubernetes, build test and deploy your projects like a pro
Gitlab ci e kubernetes, build test and deploy your projects like a proGitlab ci e kubernetes, build test and deploy your projects like a pro
Gitlab ci e kubernetes, build test and deploy your projects like a pro
 
Set up a Development Environment in 5 Minutes
Set up a Development Environment in 5 MinutesSet up a Development Environment in 5 Minutes
Set up a Development Environment in 5 Minutes
 
DockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best PracticesDockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best Practices
 
DCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best PracticesDCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best Practices
 
Adventures in docker compose
Adventures in docker composeAdventures in docker compose
Adventures in docker compose
 
Dockerizing Ruby Applications - The Best Practices
Dockerizing Ruby Applications - The Best PracticesDockerizing Ruby Applications - The Best Practices
Dockerizing Ruby Applications - The Best Practices
 
Ruby microservices with Docker - Sergii Koba
Ruby microservices with Docker -  Sergii KobaRuby microservices with Docker -  Sergii Koba
Ruby microservices with Docker - Sergii Koba
 
[Codelab 2017] Docker Ʞ쎈 및 활용 방안
[Codelab 2017] Docker Ʞ쎈 및 활용 방안[Codelab 2017] Docker Ʞ쎈 및 활용 방안
[Codelab 2017] Docker Ʞ쎈 및 활용 방안
 
Pluralsight Webinar: Simplify Your Project Builds with Docker
Pluralsight Webinar: Simplify Your Project Builds with DockerPluralsight Webinar: Simplify Your Project Builds with Docker
Pluralsight Webinar: Simplify Your Project Builds with Docker
 
Docker
DockerDocker
Docker
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflow
 
Release webinar architecture
Release webinar   architectureRelease webinar   architecture
Release webinar architecture
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 
DCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker ContainersDCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker Containers
 

Mehr von Kevin Simper

Mehr von Kevin Simper (10)

Why is my build times so long?
Why is my build times so long?Why is my build times so long?
Why is my build times so long?
 
Building a game with WebVR
Building a game with WebVRBuilding a game with WebVR
Building a game with WebVR
 
How to create a CV
How to create a CVHow to create a CV
How to create a CV
 
Building P2P in the browser for zero cost
Building P2P in the browser for zero costBuilding P2P in the browser for zero cost
Building P2P in the browser for zero cost
 
How Kubernetes allows your Startup to scale
How Kubernetes allows your Startup to scaleHow Kubernetes allows your Startup to scale
How Kubernetes allows your Startup to scale
 
Contributing Open-Source workshop
Contributing Open-Source workshopContributing Open-Source workshop
Contributing Open-Source workshop
 
WebVR is now accessible
WebVR is now accessibleWebVR is now accessible
WebVR is now accessible
 
Kubernetes at Google Cloud Community Copenhagen
Kubernetes at Google Cloud Community CopenhagenKubernetes at Google Cloud Community Copenhagen
Kubernetes at Google Cloud Community Copenhagen
 
Making Docker and Kubernetes a success at your Company
Making Docker and Kubernetes a success at your CompanyMaking Docker and Kubernetes a success at your Company
Making Docker and Kubernetes a success at your Company
 
Hack4dk presentation
Hack4dk presentationHack4dk presentation
Hack4dk presentation
 

KĂŒrzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

KĂŒrzlich hochgeladen (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Docker Best Practices in development and Production