how to upgrade jenkins in docker

# I'll keep it as "jenkins", you can use "jenkins_home" if you wish
mkdir -p $HOME/jenkins
# if you're using other names, replace $HOME/jenkins with your choice
# in case you want to change port, use this
# -e JENKINS_OPTS="--httpPort=80" (remember to change 8080:8080 below to 80:80)
docker container run \
--name jenkins \
-p 8080:8080 -p 50000:50000 \
-v $HOME/jenkins:/var/jenkins_home \
-d \
jenkins

#using host's root with -u 0
docker container exec -u 0 -it jenkins bash
# inside the container, using 2.89.2 as example
wget http://updates.jenkins-ci.org/download/war/2.89.2/jenkins.war
mv ./jenkins.war /usr/share/jenkins
# exit contaienr (inside container)
exit
# restart container (from your server)
docker container restart jenkins
chown jenkins:jenkins /usr/share/jenkins/jenkins.war (updated)
# exit contaienr (inside container)
exit
# restart container (from your server)
docker container restart jenkins


### Second Method

## SourceUrlLink: https://batmat.net/2018/09/07/how-to-run-and-upgrade-jenkins-using-the-official-docker-image/

#How to run Jenkins official Docker image and keep data

docker volume create jenkins-data
docker run --name jenkins-production \
           --detach \
           -p 50000:50000 \
           -p 8080:8080 \
           -v jenkins-data:/var/jenkins_home \
           jenkins/jenkins:2.107.3
# If run for the first time, just run the following to get the admin
# password once it has finished starting
docker exec jenkins-production bash -c 'cat $JENKINS_HOME/secrets/initialAdminPassword'

#How to upgrade your instance to a more recent version

docker stop jenkins-production
docker rm jenkins-production # just temporarily docker rename it instead if that makes you worried
docker run --name jenkins-production \
           --detach \
           -p 50000:50000 \
           -p 8080:8080 \
           -v jenkins-data:/var/jenkins_home \
           jenkins/jenkins:2.121.3

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source