Skip to main content
  1. Posts/

Jenkins Dood Setup

·349 words·2 mins· loading · loading · ·
DevOps CI/CD Jenkins Docker
Table of Contents

While Docker inside Docker (DinD) has been the go-to for running Docker within Jenkins, it’s not without its pitfalls, like security snafus and performance slumps. Enter Docker outside of Docker (DooD) – the savvy alternative. Let’s dive into setting up Jenkins with DooD and streamline our workflow.

What’s DooD All About?
#

DooD leverages the Docker engine of the host where Jenkins is running, steering clear of the complexities and overheads associated with DinD. By managing Docker containers externally, DooD simplifies the Jenkins-Docker tango.

Getting Things Set Up
#

1. Docker Installation on Jenkins Server
#

First off, let’s get Docker up and running on your Jenkins server. If you’re navigating the Linux seas, cast this spell in your terminal:

curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

2. Boarding Jenkins User onto the Docker Group
#

Grant Jenkins user the keys to the Docker kingdom by adding it to the Docker group. Fire up the following command:

sudo usermod -aG docker jenkins

To cement the changes, give Jenkins a quick reboot:

sudo systemctl restart jenkins

3. Decking Out Jenkins with the Docker Plugin
#

Navigate to the ‘Manage Plugins’ section in the Jenkins admin page, scout for the ‘Docker Plugin’, and hit install.

4. Setting Sail with Jenkins Credentials for Docker Communication
#

Secure the communication lines between Jenkins and the Docker host by configuring credentials in Jenkins. This step ensures that Jenkins can build Docker images and marshall containers without a hitch.

5. Unleashing Docker in Jenkins Pipelines
#

Now, your Jenkins pipelines can harness the power of Docker commands. Here’s a snippet of a Jenkinsfile that builds and deploys with Docker:

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                script {
                    docker.build("my-image:${env.BUILD_ID}")
                }
            }
        }
        stage('Deploy') {
            steps {
                script {
                    docker.run("my-image:${env.BUILD_ID}")
                }
            }
        }
    }
}

Wrapping Up
#

By embracing the Docker outside of Docker (DooD) approach in Jenkins, you pave the way for safer, more efficient Dockerized builds and deployments. It’s a significant leg-up for your CI/CD pipeline, leveraging the power of Docker containers while sidestepping the hassles of DinD. Happy automating!