SlideShare a Scribd company logo
CI with Docker-in-Docker
Mukta Aphale
@muktaa mukta@velotio.com
AGENDA
● Recap: CI, Jenkins
● Jenkins + Docker
● Docker in Docker problems
● 3 ways to solve docker-in-docker
● Jenkins with Docker-in-Docker: Simplest way
● Advantages of dind in CI pipeline
● VP Devops & Cloud, Velotio Technologies
● (We are hiring!!) => mukta@velotio.com
● Developer for 1 decade and in Devops for another decade!
● (Probably successful) Entrepreneur
● Love to solve problems creatively
● Love to travel, cook, paint, explore and meet people
● Mother to two (handsome) boys!
@muktaa mukta@velotio.com
“Run everything inside Docker containers. Even Docker itself…!”
Quick Recap
● Docker Runtime
● Continuous Integration
● Jenkins
● Jenkins in Docker
This is the problem:
Building container apps on Jenkins which is
running as a container
Docker in Docker Problems
● When starting a container, the “inner Docker”
might try to apply security profiles that will
conflict or confuse the “outer Docker.”
● When you run Docker in Docker, the outer
Docker runs on top of a normal filesystem but
the inner Docker runs on top of a
copy-on-write system
● Handling build cache: if your CI system does
builds and rebuilds, each time you’ll restart
your Docker-in-Docker container, you might
be nuking its cache
And then there was light…
“They didn’t know it was impossible, so they did it.” - Mark Twain
● Sysbox
○ Container runtime, based on runc,
○ Enables to run Docker-in-Docker securely and easily, integrating with existing CI tools
seamlessly
○ https://github.com/nestybox/sysbox
● Socket Solution
○ Run docker with the default Unix socket docker.sock as a volume
○ docker run -v /var/run/docker.sock:/var/run/docker.sock -ti docker
○ Security Risks
● Dind
○ Use official Docker image with dind tag: docker run --privileged -d --name dind-test docker:dind
○ Outer container runs in privileged mode
Using disposable containers in CI
https://stefanprodan.com/2016/continuous-integration-with-jenkins-and-disposable-containers/
Jenkins Pipeline with Docker
Jenkins Master
Docker Plugin
Docker Host, API
Docker Image
Configure Docker &
Agent (Jenkins ->
Config -> Cloud ->
Docker)
Jenkins Job
https://narenchejara.medium.com/how-to-configure-docker-container-as-build-slaves-for-jenkins-d7795f78402d
Jenkins Setup with Docker-in-Docker
1. Run Jenkins in container using official image (docker:dind)
a. Customized image: https://github.com/4OH4/jenkins-docker
2. Or, Clone repo and build image
docker run -it -p 8080:8080 -p 50000:50000 
-v jenkins_home:/var/jenkins_home 
-v /var/run/docker.sock:/var/run/docker.sock 
--restart unless-stopped 
4oh4/jenkins-docker
docker build -t jenkins-docker .
docker run -it -p 8080:8080 -p 50000:50000 
-v jenkins_home:/var/jenkins_home 
-v /var/run/docker.sock:/var/run/docker.sock 
--restart unless-stopped 
4oh4/jenkins-docker
Advantages of using Docker-in-Docker in CI
● On demand build environments
● No need for dedicated VMs
● Useful for microservices which are written in different languages
● Cost effective
● Better automation of continuous testing
● Very useful for performance testing
References
https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
https://medium.com/swlh/quickstart-ci-with-jenkins-and-docker-in-docker-c3f7174e
e9ff
https://itnext.io/docker-in-docker-521958d34efd
https://stefanprodan.com/2016/continuous-integration-with-jenkins-and-disposable
-containers/
Thank You!

More Related Content

PDF
Exploring Docker in CI/CD
PPTX
CI, CD with Docker, Jenkins and Tutum
PDF
Docker + jenkins in the enterprise (3)
PDF
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
PDF
Docker and Puppet for Continuous Integration
PDF
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
PDF
Dockerized maven
PPTX
Using Docker EE in a CI/CD Workflow
Exploring Docker in CI/CD
CI, CD with Docker, Jenkins and Tutum
Docker + jenkins in the enterprise (3)
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
Docker and Puppet for Continuous Integration
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
Dockerized maven
Using Docker EE in a CI/CD Workflow

Similar to CI with Docker in Docker (20)

PPTX
Dockerandjenkins citz2014
PDF
Software industrialization
PDF
DCSF 19 Building Your Development Pipeline
PDF
DCEU 18: Building Your Development Pipeline
PDF
Continuous Integration/Deployment with Docker and Jenkins
PDF
LXC to Docker Via Continuous Delivery
PPTX
IM5- Introduction to DevOps tooools.pptx
PPTX
Blue Whale in an Enterprise Pond
PPTX
Docker and Jenkins Pipeline
PPTX
MHA2018 - Docker and Jenkins Pipeline for Continuous integration - Mark Waite
PDF
Built in ci-cd with kubernetes, jenkins and helm
PDF
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
PPTX
Delivering eBay's CI Solution with Apache Mesos & Docker - DockerCon 2014
PPTX
DockerCon14 eBay
PPTX
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
PDF
Ansible docker
PDF
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
PDF
From Monolith to Docker Distributed Applications
PDF
Continuous Integration using Docker & Jenkins
PDF
Docker for tooling
Dockerandjenkins citz2014
Software industrialization
DCSF 19 Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
Continuous Integration/Deployment with Docker and Jenkins
LXC to Docker Via Continuous Delivery
IM5- Introduction to DevOps tooools.pptx
Blue Whale in an Enterprise Pond
Docker and Jenkins Pipeline
MHA2018 - Docker and Jenkins Pipeline for Continuous integration - Mark Waite
Built in ci-cd with kubernetes, jenkins and helm
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
Delivering eBay's CI Solution with Apache Mesos & Docker - DockerCon 2014
DockerCon14 eBay
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Ansible docker
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
From Monolith to Docker Distributed Applications
Continuous Integration using Docker & Jenkins
Docker for tooling
Ad

More from Mukta Aphale (10)

PDF
Using Docker for Testing
PDF
Baking Docker Using Chef
PDF
What is DevOps?
PDF
Application Monitoring using Datadog
PPTX
Continuous Testing using Shippable and Docker
PPTX
What is dev ops?
PPTX
MomOps in DevOps
PPTX
Docker and configuration management
PPTX
Baking docker using chef
PPTX
Ice breaker with dev ops
Using Docker for Testing
Baking Docker Using Chef
What is DevOps?
Application Monitoring using Datadog
Continuous Testing using Shippable and Docker
What is dev ops?
MomOps in DevOps
Docker and configuration management
Baking docker using chef
Ice breaker with dev ops
Ad

Recently uploaded (20)

PPTX
A Presentation on Artificial Intelligence
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Empathic Computing: Creating Shared Understanding
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Cloud computing and distributed systems.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation theory and applications.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
A Presentation on Artificial Intelligence
The Rise and Fall of 3GPP – Time for a Sabbatical?
Building Integrated photovoltaic BIPV_UPV.pdf
Big Data Technologies - Introduction.pptx
NewMind AI Weekly Chronicles - August'25-Week II
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
Empathic Computing: Creating Shared Understanding
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
Cloud computing and distributed systems.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation theory and applications.pdf
sap open course for s4hana steps from ECC to s4
Review of recent advances in non-invasive hemoglobin estimation
“AI and Expert System Decision Support & Business Intelligence Systems”

CI with Docker in Docker

  • 1. CI with Docker-in-Docker Mukta Aphale @muktaa mukta@velotio.com
  • 2. AGENDA ● Recap: CI, Jenkins ● Jenkins + Docker ● Docker in Docker problems ● 3 ways to solve docker-in-docker ● Jenkins with Docker-in-Docker: Simplest way ● Advantages of dind in CI pipeline ● VP Devops & Cloud, Velotio Technologies ● (We are hiring!!) => mukta@velotio.com ● Developer for 1 decade and in Devops for another decade! ● (Probably successful) Entrepreneur ● Love to solve problems creatively ● Love to travel, cook, paint, explore and meet people ● Mother to two (handsome) boys! @muktaa mukta@velotio.com
  • 3. “Run everything inside Docker containers. Even Docker itself…!”
  • 4. Quick Recap ● Docker Runtime ● Continuous Integration ● Jenkins ● Jenkins in Docker
  • 5. This is the problem: Building container apps on Jenkins which is running as a container Docker in Docker Problems ● When starting a container, the “inner Docker” might try to apply security profiles that will conflict or confuse the “outer Docker.” ● When you run Docker in Docker, the outer Docker runs on top of a normal filesystem but the inner Docker runs on top of a copy-on-write system ● Handling build cache: if your CI system does builds and rebuilds, each time you’ll restart your Docker-in-Docker container, you might be nuking its cache
  • 6. And then there was light… “They didn’t know it was impossible, so they did it.” - Mark Twain ● Sysbox ○ Container runtime, based on runc, ○ Enables to run Docker-in-Docker securely and easily, integrating with existing CI tools seamlessly ○ https://github.com/nestybox/sysbox ● Socket Solution ○ Run docker with the default Unix socket docker.sock as a volume ○ docker run -v /var/run/docker.sock:/var/run/docker.sock -ti docker ○ Security Risks ● Dind ○ Use official Docker image with dind tag: docker run --privileged -d --name dind-test docker:dind ○ Outer container runs in privileged mode
  • 7. Using disposable containers in CI https://stefanprodan.com/2016/continuous-integration-with-jenkins-and-disposable-containers/
  • 8. Jenkins Pipeline with Docker Jenkins Master Docker Plugin Docker Host, API Docker Image Configure Docker & Agent (Jenkins -> Config -> Cloud -> Docker) Jenkins Job https://narenchejara.medium.com/how-to-configure-docker-container-as-build-slaves-for-jenkins-d7795f78402d
  • 9. Jenkins Setup with Docker-in-Docker 1. Run Jenkins in container using official image (docker:dind) a. Customized image: https://github.com/4OH4/jenkins-docker 2. Or, Clone repo and build image docker run -it -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock --restart unless-stopped 4oh4/jenkins-docker docker build -t jenkins-docker . docker run -it -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock --restart unless-stopped 4oh4/jenkins-docker
  • 10. Advantages of using Docker-in-Docker in CI ● On demand build environments ● No need for dedicated VMs ● Useful for microservices which are written in different languages ● Cost effective ● Better automation of continuous testing ● Very useful for performance testing