Updating the Jenkins: Docker way

Updating the Jenkins: Docker way

Best practice to upgrade Jenkins docker containers.

Important Pointers:

  • always prefer docker volumes. This method works if you are running Jenkins docker container with mounted volume.

Traditional way is to get into the container and download the new war file, replace & finally restart the container.

There are chances container may not start and due any incorrect changes. :(

let’s look at the more effective way to meet this.

  1. Log in to your host server.
  2. Directly pull a Jenkins docker image with your desired version. docker pull jenkins/jenkins:2.54

(assuming 2.154 is the latest) If you are planning to install any additional packages, it is better to have dockerfile and build your own image.

  1. Stop your current docker container.

    docker stop CONTAINER_ID

  2. Start your new container with the existing location of jenkinshome.

    docker container run \ — name jenkins \ -p 8080:8080 -p 50000:50000 \ -v $HOME/jenkins:/var/jenkins_home \ -d \ jenkins/jenkins:2.514

$HOME is the your local directory for docker volume.

  1. Check for the running container. Now and access your Jenkins web with latest version

Note: Having a separate volume for Jenkins home makes easier to upgrade the Jenkins version in clicks. And all our settings, personalisation in place.

peace!