Install Jenkins from Docker Image & Create Pipeline |Video upload date:  · Duration: PT14M45S  · Language: EN

Quick guide to run Jenkins in Docker and create a basic Jenkins pipeline using a Jenkinsfile and simple steps.

If you want a Jenkins server that is portable enough to survive developer tantrums and cloud provider mood swings then running Jenkins inside Docker is the pragmatic choice. This guide walks through pulling the official Jenkins image starting a container with persistent storage creating a basic pipeline and keeping your Jenkinsfile in source control so pipeline changes are reviewed like actual code.

Why run Jenkins in Docker

Containers give you repeatable builds and faster onboarding. For DevOps teams the benefits are obvious automation friendly portable and less time spent fixing environment drift. You get a fully functional Jenkins server without wrestling with system packages or mysterious dependency conflicts.

Quick overview of the flow

  • Pull the Jenkins Docker image
  • Start the Jenkins container with a mounted volume for persistence
  • Unlock Jenkins and install recommended plugins
  • Create a pipeline job and add a Jenkinsfile to your repo
  • Run the pipeline and inspect console logs for real time feedback

Pull the Jenkins Docker image

Use the official image to avoid getting surprised by unofficial forks. The LTS tag is a sensible default for most teams.

docker pull jenkins/jenkins:lts

Start the Jenkins container with persistent volume

Mount a host or named volume to keep job history plugin data and config across container restarts. Expose the web UI and the agent port if you plan to use Jenkins agents in containers later.

docker run -d -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home --name jenkins jenkins/jenkins:lts

Unlock Jenkins and install recommended plugins

On first start Jenkins asks for an initial admin password. You can fetch it from the container logs or by reading the file inside the running container.

docker logs jenkins
# or
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword

Use the web UI to create an admin user and install the recommended plugin set unless you like custom pain. The recommended set covers most common SCM and pipeline needs.

Create a pipeline job and add a Jenkinsfile

In the Jenkins UI create a new pipeline project and point it to your repository or paste a pipeline script. The best practice is to put a declarative Jenkinsfile next to your code so CI lives with the repo and goes through code review.

pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        checkout scm
      }
    }
    stage('Build') {
      steps {
        sh 'mvn -B -DskipTests package'
      }
    }
    stage('Test') {
      steps {
        sh 'mvn test'
      }
    }
  }
  post {
    always {
      archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
      junit '**/target/surefire-reports/*.xml'
    }
  }
}

Run the pipeline and inspect logs

Trigger a build from the dashboard or configure a webhook from your SCM provider to kick off runs on push. Watch the console output for each stage. Jenkins will tell you exactly which command failed and why the build had a temper tantrum.

Tips and best practices for Docker based Jenkins

  • Keep the Jenkinsfile in the repo so CI changes are reviewed like code
  • Use a named volume or bind mount for /var/jenkins_home to preserve jobs and plugins
  • Prefer the LTS image for stability unless you enjoy living on the edge
  • Script plugin installation for repeatable setups in automation and onboarding
  • Back up your Jenkins config periodically especially before major plugin updates

That is the minimal path to run Jenkins in a container and get a working CI CD pipeline up fast. It is repeatable portable and friendly for teams practicing DevOps. Now go add automation and let your CI do the boring work while you take all the credit.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.