SlideShare a Scribd company logo
Simplify your Jenkins Projects with
Docker Multi-Stage Builds
Eric Smalling - Solution Architect, Docker Inc.
Simplify your Jenkins Projects
with Docker Multi-Stage Builds
Eric Smalling
Solution Architect
Docker Inc.
Agenda
• Docker images 101
•Building images via Jenkins
• Image size challenges
• Old way: Using Docker image builder pattern
• New way: Docker multi-stage builds
• Demos
• Resources for more info
Introduction
• Eric Smalling
–Solution Architect
Docker Customer Success Team
• ~25 years in software development, architecture,
version control admin, etc…
–Java / J2EE, C, Python, etc
–Puppet, Ansible
–Git, SVN, CVS, ClearCase, VSS, PVCS
• ~10 years in build & test automation
–Primarily Jenkins for CI, including some very large scale
implementations
–Testing with Selenium, Fitnesse, RESTAssured, SOAPUI,
Puppet-RSpec, etc
–Docker user since pre-1.0 days
•Dallas/Fort Worth Jenkins Area Meetup (JAM)
coordinator.
Docker images 101
• Images are built up from a series of
layers
• Each layer represents changes from
the prior
• Layers are immutable (read-only)
and referenced by hashes and
optional tags
•Containers run with a file system
based on an image with a thin
read/write layer added.
(plus any volume mounts specified)
Image credit: https://docs.docker.com/engine/userguide/storagedriver/imagesandcontainers
Docker images 101
• Multiple containers
running on the same
image share the
underlying layers.
• Each container
overlays it’s own
container read/write
layer.
Image credit: https://docs.docker.com/engine/userguide/storagedriver/imagesandcontainers
Building images via Jenkins
• 3 usual methods:
– Shell step
– Docker build
step (plugin)
– Pipeline DSL
Building images via Jenkins
...
Image size challenges
• Image layers have size and they add up!
• CI can compound this
• Example: dockercraft
–Base golang:1.7.1 = 672MB
–Docker 17.06 CE = 98MB
–Cuberite = 12MB
–Misc = 56 MB
–Total: 838MB!
Image size challenges
• Image layers have size and they add up!
• CI can compound this
• Example: dockercraft
–Base golang:1.7.1 = 672MB debian:jessie = 123MB
–Docker 17.06 CE = 98MB
–Cuberite = 12MB
–Misc = 56 MB
–Total: 838MB! 289MB
Changing the base all by itself
saves us 549MB!
Image size challenges
How can we get rid of GoLang if it’s needed?
Build in Jenkins-land, then Dockerize
• Use Jenkins build steps to do the construction in the
workspace followed by a Docker image build with just the
needed artifacts
node {
def app
stage('SCM clone') {
checkout scm
}
stage ('Build Image') {
app = docker.build("m
}
stage ('Print image info')
{
sh 'docker image ls my
sh 'docker image histo
}
}
Jenkinsfile
FROM debian:jessie
COPY build_artifacts /
# Copy Dockercraft config and p
COPY ./config /srv/Server
COPY ./docs/img/logo64x64.png /
COPY ./Docker /srv/Server/Plugi
Dockerfile
Build
artifacts
Small
deployment
image
Docker build pattern
• Using Docker image builder pattern, we break the
Dockerfile up into multiple files, the final one being the
one that produces the image to ship.
FROM golang:1.7.1
ENV DOCKER_VERSION 1.12.1
ENV CUBERITE_BUILD 630
# Copy latest docker client(s)
RUN curl -sSL -o docker.tgz ht
tar -xvf
docker.tgz
chmod +x
/bin/docker
ln -s
/bin/docker /b
# Download Cuberite server (Mi
WORKDIR /srv
RUN curl "https://builds.cuber
# Copy Dockercraft config and
COPY ./config /srv/Server
COPY ./docs/img/logo64x64.png
COPY ./Docker /srv/Server/Plug
# Copy Go code and install
Dockerfile FROM golang:1.7.1
ENV DOCKER_VERSION 1.12.1
ENV CUBERITE_BUILD 630
# Copy latest docker client(s)
RUN curl -sSL -o docker.tgz ht
tar -xvf
docker.tgz
chmod +x
/bin/docker
ln -s
/bin/docker /b
Dockerfile
FROM debian:jessie
COPY build_artifacts /
# Copy Dockercraft config and p
COPY ./config /srv/Server
COPY ./docs/img/logo64x64.png /
COPY ./Docker /srv/Server/Plugi
Dockerfile
Big build
image
Smaller
deployment
image
node {
def app
stage('SCM clone') {
checkout scm
}
stage ('Build Image') {
app = docker.build("m
}
stage ('Print image info')
{
sh 'docker image ls my
sh 'docker image histo
}
}
Jenkinsfile
Old School Way
• Implementing some fashion of the builder pattern via build
steps or multiple projects triggering each other.
FROM golang:1.7.1
ENV DOCKER_VERSION 1.12.1
ENV CUBERITE_BUILD 630
# Copy latest docker client(s)
RUN curl -sSL -o docker.tgz ht
tar -xvf
docker.tgz
chmod +x
/bin/docker
ln -s
/bin/docker /b
Dockerfile
FROM debian:jessie
COPY build_artifacts /
# Copy Dockercraft config and p
COPY ./config /srv/Server
COPY ./docs/img/logo64x64.png /
COPY ./Docker /srv/Server/Plugi
Dockerfile
Big build
image
Smaller
deployment
image
https://cdn.meme.am/instances/500x/76014521/you-cant-break-a-build-if-its-too-complicated-to-change.jpg
Docker image builds demo (old way)
Demo time!
Docker Multi-Stage builds
• Multiple stages in one Dockerfile
• Each stage starts with a new “FROM” line
• Layers from final stage are the only ones in your image
• Stages can refer back to and copy files from earlier stages
• Requires Docker CE 17.05+ / EE 17.06+
Example Dockerfile with multi-stage:
Example Dockerfile with multi-stage:
wget
docker cuberite
}alpine
golang debian
myappdockercraft
Minecraft, really?
Not everyone works at Unicorn shops that code in GoLang all
day and visualize their Docker containers in Minecraft
http://gph.is/1UK1ZFa
Simple web app:
• ReactJS front-end
• Spring Boot, Java back-end
• Deployed in single container
AtSeaApp Demo
AtSeaApp Demo
Demo time!
Resources
• Dockercon 2017 keynote introducing Multi-Stage Builds:
https://youtu.be/hwkqju_BXEo?t=24m26s
• Abby Fuller, Creating Effective Images:
https://youtu.be/pPsREQbf3PA
•Nicolas Frankel, A Dockerfile for Maven-Based GitHub
Projects: https://goo.gl/hWv3NM
Resources
COPENHAGEN, DENMARK
Q & A
Contact me
Eric Smalling
Solution Architect at Docker
eric.smalling@docker.com
ericsmalling
}
COPENHAGEN, DENMARK
Simply your Jenkins Projects with Docker Multi-Stage Builds

More Related Content

What's hot

Kubernetes security
Kubernetes securityKubernetes security
Kubernetes security
Thomas Fricke
 
Gitlab ci-cd
Gitlab ci-cdGitlab ci-cd
Gitlab ci-cd
Dan MAGIER
 
Introduction to Tekton
Introduction to TektonIntroduction to Tekton
Introduction to Tekton
Victor Iglesias
 
Jenkins vs GitLab CI
Jenkins vs GitLab CIJenkins vs GitLab CI
Jenkins vs GitLab CI
CEE-SEC(R)
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
Volodymyr Shynkar
 
GitHub Actions in action
GitHub Actions in actionGitHub Actions in action
GitHub Actions in action
Oleksii Holub
 
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDKubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Sunnyvale
 
AManaging Kong API Gateway with Terraform
AManaging Kong API Gateway with TerraformAManaging Kong API Gateway with Terraform
AManaging Kong API Gateway with Terraform
Byungjin Park
 
CI, CD, CT, Deploy, IaaS, DevOps, Stage
CI, CD, CT, Deploy, IaaS, DevOps, StageCI, CD, CT, Deploy, IaaS, DevOps, Stage
CI, CD, CT, Deploy, IaaS, DevOps, Stage
Artur Basak
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
Bo-Yi Wu
 
Kubernetes in Docker
Kubernetes in DockerKubernetes in Docker
Kubernetes in Docker
Docker, Inc.
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
Kumar Shìvam
 
CI/CD on AWS
CI/CD on AWSCI/CD on AWS
CI/CD on AWS
Amazon Web Services
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
Otto Kekäläinen
 
Swagger / Quick Start Guide
Swagger / Quick Start GuideSwagger / Quick Start Guide
Swagger / Quick Start Guide
Andrii Gakhov
 
Jenkins
JenkinsJenkins
Docker multi-stage build
Docker multi-stage buildDocker multi-stage build
Docker multi-stage build
Alexei Ledenev
 
CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton
Araf Karsh Hamid
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICD
Knoldus Inc.
 

What's hot (20)

Kubernetes security
Kubernetes securityKubernetes security
Kubernetes security
 
Gitlab ci-cd
Gitlab ci-cdGitlab ci-cd
Gitlab ci-cd
 
CICD with Jenkins
CICD with JenkinsCICD with Jenkins
CICD with Jenkins
 
Introduction to Tekton
Introduction to TektonIntroduction to Tekton
Introduction to Tekton
 
Jenkins vs GitLab CI
Jenkins vs GitLab CIJenkins vs GitLab CI
Jenkins vs GitLab CI
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
 
GitHub Actions in action
GitHub Actions in actionGitHub Actions in action
GitHub Actions in action
 
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDKubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
 
AManaging Kong API Gateway with Terraform
AManaging Kong API Gateway with TerraformAManaging Kong API Gateway with Terraform
AManaging Kong API Gateway with Terraform
 
CI, CD, CT, Deploy, IaaS, DevOps, Stage
CI, CD, CT, Deploy, IaaS, DevOps, StageCI, CD, CT, Deploy, IaaS, DevOps, Stage
CI, CD, CT, Deploy, IaaS, DevOps, Stage
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
 
Kubernetes in Docker
Kubernetes in DockerKubernetes in Docker
Kubernetes in Docker
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
 
CI/CD on AWS
CI/CD on AWSCI/CD on AWS
CI/CD on AWS
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 
Swagger / Quick Start Guide
Swagger / Quick Start GuideSwagger / Quick Start Guide
Swagger / Quick Start Guide
 
Jenkins
JenkinsJenkins
Jenkins
 
Docker multi-stage build
Docker multi-stage buildDocker multi-stage build
Docker multi-stage build
 
CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICD
 

Similar to Simply your Jenkins Projects with Docker Multi-Stage Builds

Reduce DevOps Friction with Docker & Jenkins by Andy Pemberton, Cloudbees
Reduce DevOps Friction with Docker & Jenkins by Andy Pemberton, CloudbeesReduce DevOps Friction with Docker & Jenkins by Andy Pemberton, Cloudbees
Reduce DevOps Friction with Docker & Jenkins by Andy Pemberton, Cloudbees
Docker, Inc.
 
Rapid Development With Docker Compose
Rapid Development With Docker ComposeRapid Development With Docker Compose
Rapid Development With Docker Compose
Justin Crown
 
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Docker, Inc.
 
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
Sencha
 
Serverless containers … with source-to-image
Serverless containers  … with source-to-imageServerless containers  … with source-to-image
Serverless containers … with source-to-image
Josef Adersberger
 
Serverless Container with Source2Image
Serverless Container with Source2ImageServerless Container with Source2Image
Serverless Container with Source2Image
QAware GmbH
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
Docker, Inc.
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
Docker, Inc.
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
Rafe Colton
 
Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)
Eric Smalling
 
The Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptThe Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build Script
Docker, Inc.
 
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
inside-BigData.com
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with docker
Michelle Liu
 
ABCing docker with environments - workshop
ABCing docker with environments - workshopABCing docker with environments - workshop
ABCing docker with environments - workshop
VodqaBLR
 
Docker Containers: Developer’s experience and building robust developer envir...
Docker Containers: Developer’s experience and building robust developer envir...Docker Containers: Developer’s experience and building robust developer envir...
Docker Containers: Developer’s experience and building robust developer envir...
Future Cloud Summit
 
Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous Integration
Giacomo Vacca
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
Giacomo Vacca
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
Naukri.com
 
Introducción a contenedores Docker
Introducción a contenedores DockerIntroducción a contenedores Docker
Introducción a contenedores Docker
Software Guru
 
How to _docker
How to _dockerHow to _docker
How to _docker
Abdur Rab Marjan
 

Similar to Simply your Jenkins Projects with Docker Multi-Stage Builds (20)

Reduce DevOps Friction with Docker & Jenkins by Andy Pemberton, Cloudbees
Reduce DevOps Friction with Docker & Jenkins by Andy Pemberton, CloudbeesReduce DevOps Friction with Docker & Jenkins by Andy Pemberton, Cloudbees
Reduce DevOps Friction with Docker & Jenkins by Andy Pemberton, Cloudbees
 
Rapid Development With Docker Compose
Rapid Development With Docker ComposeRapid Development With Docker Compose
Rapid Development With Docker Compose
 
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
 
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
 
Serverless containers … with source-to-image
Serverless containers  … with source-to-imageServerless containers  … with source-to-image
Serverless containers … with source-to-image
 
Serverless Container with Source2Image
Serverless Container with Source2ImageServerless Container with Source2Image
Serverless Container with Source2Image
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
 
Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)
 
The Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptThe Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build Script
 
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
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with docker
 
ABCing docker with environments - workshop
ABCing docker with environments - workshopABCing docker with environments - workshop
ABCing docker with environments - workshop
 
Docker Containers: Developer’s experience and building robust developer envir...
Docker Containers: Developer’s experience and building robust developer envir...Docker Containers: Developer’s experience and building robust developer envir...
Docker Containers: Developer’s experience and building robust developer envir...
 
Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous Integration
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
 
Introducción a contenedores Docker
Introducción a contenedores DockerIntroducción a contenedores Docker
Introducción a contenedores Docker
 
How to _docker
How to _dockerHow to _docker
How to _docker
 

More from Eric Smalling

DockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdf
DockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdfDockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdf
DockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdf
Eric Smalling
 
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
Eric Smalling
 
ATO 2022 - Why should devs care about container security.pdf
ATO 2022 - Why should devs care about container security.pdfATO 2022 - Why should devs care about container security.pdf
ATO 2022 - Why should devs care about container security.pdf
Eric Smalling
 
KubeCon NA 2022 - Hardening against Kubernetes Hacks.pdf
KubeCon NA 2022 - Hardening against Kubernetes Hacks.pdfKubeCon NA 2022 - Hardening against Kubernetes Hacks.pdf
KubeCon NA 2022 - Hardening against Kubernetes Hacks.pdf
Eric Smalling
 
DevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent it
DevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent itDevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent it
DevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent it
Eric Smalling
 
Look Ma' - Building Java and Go based container images without Dockerfiles
Look Ma' - Building Java and Go based container images without DockerfilesLook Ma' - Building Java and Go based container images without Dockerfiles
Look Ma' - Building Java and Go based container images without Dockerfiles
Eric Smalling
 
Container Stranger Danger - Why should devs care about container security
Container Stranger Danger - Why should devs care about container securityContainer Stranger Danger - Why should devs care about container security
Container Stranger Danger - Why should devs care about container security
Eric Smalling
 
SCaLE 19x - Eric Smalling - Hardening against Kubernetes Hacks
SCaLE 19x - Eric Smalling - Hardening against Kubernetes HacksSCaLE 19x - Eric Smalling - Hardening against Kubernetes Hacks
SCaLE 19x - Eric Smalling - Hardening against Kubernetes Hacks
Eric Smalling
 
DockerCon 2022 - From legacy to Kubernetes, securely & quickly
DockerCon 2022 - From legacy to Kubernetes, securely & quicklyDockerCon 2022 - From legacy to Kubernetes, securely & quickly
DockerCon 2022 - From legacy to Kubernetes, securely & quickly
Eric Smalling
 
Python Web Conference 2022 - Why should devs care about container security.pdf
Python Web Conference 2022 - Why should devs care about container security.pdfPython Web Conference 2022 - Why should devs care about container security.pdf
Python Web Conference 2022 - Why should devs care about container security.pdf
Eric Smalling
 
Why should developers care about container security?
Why should developers care about container security?Why should developers care about container security?
Why should developers care about container security?
Eric Smalling
 
AWS live hack: Docker + Snyk Container on AWS
AWS live hack: Docker + Snyk Container on AWSAWS live hack: Docker + Snyk Container on AWS
AWS live hack: Docker + Snyk Container on AWS
Eric Smalling
 
AWS live hack: Atlassian + Snyk OSS on AWS
AWS live hack: Atlassian + Snyk OSS on AWSAWS live hack: Atlassian + Snyk OSS on AWS
AWS live hack: Atlassian + Snyk OSS on AWS
Eric Smalling
 
Hacking into your containers, and how to stop it!
Hacking into your containers, and how to stop it!Hacking into your containers, and how to stop it!
Hacking into your containers, and how to stop it!
Eric Smalling
 
DevSecCon Lightning 2021- Container defaults are a hackers best friend
DevSecCon Lightning 2021- Container defaults are a hackers best friendDevSecCon Lightning 2021- Container defaults are a hackers best friend
DevSecCon Lightning 2021- Container defaults are a hackers best friend
Eric Smalling
 
LFX Nov 16, 2021 - Find vulnerabilities before security knocks on your door
LFX Nov 16, 2021 - Find vulnerabilities before security knocks on your doorLFX Nov 16, 2021 - Find vulnerabilities before security knocks on your door
LFX Nov 16, 2021 - Find vulnerabilities before security knocks on your door
Eric Smalling
 
So. many. vulnerabilities. Why are containers such a mess and what to do abou...
So. many. vulnerabilities. Why are containers such a mess and what to do abou...So. many. vulnerabilities. Why are containers such a mess and what to do abou...
So. many. vulnerabilities. Why are containers such a mess and what to do abou...
Eric Smalling
 
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...
Eric Smalling
 
Best Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerBest Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with Docker
Eric Smalling
 

More from Eric Smalling (19)

DockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdf
DockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdfDockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdf
DockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdf
 
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
 
ATO 2022 - Why should devs care about container security.pdf
ATO 2022 - Why should devs care about container security.pdfATO 2022 - Why should devs care about container security.pdf
ATO 2022 - Why should devs care about container security.pdf
 
KubeCon NA 2022 - Hardening against Kubernetes Hacks.pdf
KubeCon NA 2022 - Hardening against Kubernetes Hacks.pdfKubeCon NA 2022 - Hardening against Kubernetes Hacks.pdf
KubeCon NA 2022 - Hardening against Kubernetes Hacks.pdf
 
DevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent it
DevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent itDevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent it
DevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent it
 
Look Ma' - Building Java and Go based container images without Dockerfiles
Look Ma' - Building Java and Go based container images without DockerfilesLook Ma' - Building Java and Go based container images without Dockerfiles
Look Ma' - Building Java and Go based container images without Dockerfiles
 
Container Stranger Danger - Why should devs care about container security
Container Stranger Danger - Why should devs care about container securityContainer Stranger Danger - Why should devs care about container security
Container Stranger Danger - Why should devs care about container security
 
SCaLE 19x - Eric Smalling - Hardening against Kubernetes Hacks
SCaLE 19x - Eric Smalling - Hardening against Kubernetes HacksSCaLE 19x - Eric Smalling - Hardening against Kubernetes Hacks
SCaLE 19x - Eric Smalling - Hardening against Kubernetes Hacks
 
DockerCon 2022 - From legacy to Kubernetes, securely & quickly
DockerCon 2022 - From legacy to Kubernetes, securely & quicklyDockerCon 2022 - From legacy to Kubernetes, securely & quickly
DockerCon 2022 - From legacy to Kubernetes, securely & quickly
 
Python Web Conference 2022 - Why should devs care about container security.pdf
Python Web Conference 2022 - Why should devs care about container security.pdfPython Web Conference 2022 - Why should devs care about container security.pdf
Python Web Conference 2022 - Why should devs care about container security.pdf
 
Why should developers care about container security?
Why should developers care about container security?Why should developers care about container security?
Why should developers care about container security?
 
AWS live hack: Docker + Snyk Container on AWS
AWS live hack: Docker + Snyk Container on AWSAWS live hack: Docker + Snyk Container on AWS
AWS live hack: Docker + Snyk Container on AWS
 
AWS live hack: Atlassian + Snyk OSS on AWS
AWS live hack: Atlassian + Snyk OSS on AWSAWS live hack: Atlassian + Snyk OSS on AWS
AWS live hack: Atlassian + Snyk OSS on AWS
 
Hacking into your containers, and how to stop it!
Hacking into your containers, and how to stop it!Hacking into your containers, and how to stop it!
Hacking into your containers, and how to stop it!
 
DevSecCon Lightning 2021- Container defaults are a hackers best friend
DevSecCon Lightning 2021- Container defaults are a hackers best friendDevSecCon Lightning 2021- Container defaults are a hackers best friend
DevSecCon Lightning 2021- Container defaults are a hackers best friend
 
LFX Nov 16, 2021 - Find vulnerabilities before security knocks on your door
LFX Nov 16, 2021 - Find vulnerabilities before security knocks on your doorLFX Nov 16, 2021 - Find vulnerabilities before security knocks on your door
LFX Nov 16, 2021 - Find vulnerabilities before security knocks on your door
 
So. many. vulnerabilities. Why are containers such a mess and what to do abou...
So. many. vulnerabilities. Why are containers such a mess and what to do abou...So. many. vulnerabilities. Why are containers such a mess and what to do abou...
So. many. vulnerabilities. Why are containers such a mess and what to do abou...
 
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...
 
Best Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerBest Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with Docker
 

Recently uploaded

Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
abdulrafaychaudhry
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
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
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 

Recently uploaded (20)

Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
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
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 

Simply your Jenkins Projects with Docker Multi-Stage Builds

  • 1. Simplify your Jenkins Projects with Docker Multi-Stage Builds Eric Smalling - Solution Architect, Docker Inc.
  • 2. Simplify your Jenkins Projects with Docker Multi-Stage Builds Eric Smalling Solution Architect Docker Inc.
  • 3. Agenda • Docker images 101 •Building images via Jenkins • Image size challenges • Old way: Using Docker image builder pattern • New way: Docker multi-stage builds • Demos • Resources for more info
  • 4. Introduction • Eric Smalling –Solution Architect Docker Customer Success Team • ~25 years in software development, architecture, version control admin, etc… –Java / J2EE, C, Python, etc –Puppet, Ansible –Git, SVN, CVS, ClearCase, VSS, PVCS • ~10 years in build & test automation –Primarily Jenkins for CI, including some very large scale implementations –Testing with Selenium, Fitnesse, RESTAssured, SOAPUI, Puppet-RSpec, etc –Docker user since pre-1.0 days •Dallas/Fort Worth Jenkins Area Meetup (JAM) coordinator.
  • 5. Docker images 101 • Images are built up from a series of layers • Each layer represents changes from the prior • Layers are immutable (read-only) and referenced by hashes and optional tags •Containers run with a file system based on an image with a thin read/write layer added. (plus any volume mounts specified) Image credit: https://docs.docker.com/engine/userguide/storagedriver/imagesandcontainers
  • 6. Docker images 101 • Multiple containers running on the same image share the underlying layers. • Each container overlays it’s own container read/write layer. Image credit: https://docs.docker.com/engine/userguide/storagedriver/imagesandcontainers
  • 7. Building images via Jenkins • 3 usual methods: – Shell step – Docker build step (plugin) – Pipeline DSL
  • 8. Building images via Jenkins ...
  • 9. Image size challenges • Image layers have size and they add up! • CI can compound this • Example: dockercraft –Base golang:1.7.1 = 672MB –Docker 17.06 CE = 98MB –Cuberite = 12MB –Misc = 56 MB –Total: 838MB!
  • 10. Image size challenges • Image layers have size and they add up! • CI can compound this • Example: dockercraft –Base golang:1.7.1 = 672MB debian:jessie = 123MB –Docker 17.06 CE = 98MB –Cuberite = 12MB –Misc = 56 MB –Total: 838MB! 289MB Changing the base all by itself saves us 549MB!
  • 11. Image size challenges How can we get rid of GoLang if it’s needed?
  • 12. Build in Jenkins-land, then Dockerize • Use Jenkins build steps to do the construction in the workspace followed by a Docker image build with just the needed artifacts node { def app stage('SCM clone') { checkout scm } stage ('Build Image') { app = docker.build("m } stage ('Print image info') { sh 'docker image ls my sh 'docker image histo } } Jenkinsfile FROM debian:jessie COPY build_artifacts / # Copy Dockercraft config and p COPY ./config /srv/Server COPY ./docs/img/logo64x64.png / COPY ./Docker /srv/Server/Plugi Dockerfile Build artifacts Small deployment image
  • 13. Docker build pattern • Using Docker image builder pattern, we break the Dockerfile up into multiple files, the final one being the one that produces the image to ship. FROM golang:1.7.1 ENV DOCKER_VERSION 1.12.1 ENV CUBERITE_BUILD 630 # Copy latest docker client(s) RUN curl -sSL -o docker.tgz ht tar -xvf docker.tgz chmod +x /bin/docker ln -s /bin/docker /b # Download Cuberite server (Mi WORKDIR /srv RUN curl "https://builds.cuber # Copy Dockercraft config and COPY ./config /srv/Server COPY ./docs/img/logo64x64.png COPY ./Docker /srv/Server/Plug # Copy Go code and install Dockerfile FROM golang:1.7.1 ENV DOCKER_VERSION 1.12.1 ENV CUBERITE_BUILD 630 # Copy latest docker client(s) RUN curl -sSL -o docker.tgz ht tar -xvf docker.tgz chmod +x /bin/docker ln -s /bin/docker /b Dockerfile FROM debian:jessie COPY build_artifacts / # Copy Dockercraft config and p COPY ./config /srv/Server COPY ./docs/img/logo64x64.png / COPY ./Docker /srv/Server/Plugi Dockerfile Big build image Smaller deployment image node { def app stage('SCM clone') { checkout scm } stage ('Build Image') { app = docker.build("m } stage ('Print image info') { sh 'docker image ls my sh 'docker image histo } } Jenkinsfile
  • 14. Old School Way • Implementing some fashion of the builder pattern via build steps or multiple projects triggering each other. FROM golang:1.7.1 ENV DOCKER_VERSION 1.12.1 ENV CUBERITE_BUILD 630 # Copy latest docker client(s) RUN curl -sSL -o docker.tgz ht tar -xvf docker.tgz chmod +x /bin/docker ln -s /bin/docker /b Dockerfile FROM debian:jessie COPY build_artifacts / # Copy Dockercraft config and p COPY ./config /srv/Server COPY ./docs/img/logo64x64.png / COPY ./Docker /srv/Server/Plugi Dockerfile Big build image Smaller deployment image https://cdn.meme.am/instances/500x/76014521/you-cant-break-a-build-if-its-too-complicated-to-change.jpg
  • 15. Docker image builds demo (old way) Demo time!
  • 16. Docker Multi-Stage builds • Multiple stages in one Dockerfile • Each stage starts with a new “FROM” line • Layers from final stage are the only ones in your image • Stages can refer back to and copy files from earlier stages • Requires Docker CE 17.05+ / EE 17.06+
  • 17. Example Dockerfile with multi-stage:
  • 18. Example Dockerfile with multi-stage: wget docker cuberite }alpine golang debian myappdockercraft
  • 19. Minecraft, really? Not everyone works at Unicorn shops that code in GoLang all day and visualize their Docker containers in Minecraft http://gph.is/1UK1ZFa
  • 20. Simple web app: • ReactJS front-end • Spring Boot, Java back-end • Deployed in single container AtSeaApp Demo
  • 22. Resources • Dockercon 2017 keynote introducing Multi-Stage Builds: https://youtu.be/hwkqju_BXEo?t=24m26s • Abby Fuller, Creating Effective Images: https://youtu.be/pPsREQbf3PA •Nicolas Frankel, A Dockerfile for Maven-Based GitHub Projects: https://goo.gl/hWv3NM
  • 24. Q & A
  • 25. Contact me Eric Smalling Solution Architect at Docker eric.smalling@docker.com ericsmalling } COPENHAGEN, DENMARK