Quickstart CI with Jenkins and Docker-in-Docker
Run everything inside Docker containers, even Docker itself
tldr: If you just want to get going quickly: we use Jenkins to automate Continuous Integration tasks, and run it in a Docker container so its super-easy to setup and maintain. We also use Docker to run parts of the CI pipeline (such as builds or testing), with the CloudBees Docker Custom Build Environment plugin. Here, with a single command, we spin up a Docker container that contains Jenkins and the Docker executable, and connect it to the host daemon to avoid any conflicts:
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
This assumes you have Docker already installed on the host machine, and are running Linux (tested on Ubuntu).
We use a custom Dockerfile to add the Docker executable to the standard Jenkins LTS image. All code is here: