Skip to content

Instantly share code, notes, and snippets.

@ricardo-dlc
Last active November 16, 2024 20:04
Show Gist options
  • Save ricardo-dlc/1a6cbd9d48e4fa791b022b1eebc15de5 to your computer and use it in GitHub Desktop.
Save ricardo-dlc/1a6cbd9d48e4fa791b022b1eebc15de5 to your computer and use it in GitHub Desktop.
Update Jenkins Inside a Docker Container

First identify your image.

$ docker ps --format "{{.ID}}: {{.Image}} {{.Names}}"
3d2fb2ab2ca5: jenkins-docker jenkins-docker_1

Then login into the image as root.

$ docker container exec -u 0 -it jenkins-docker_1 /bin/bash

Now you are inside the container, download the jenkins.war file from the official site like.

# wget wget http://updates.jenkins-ci.org/download/war/2.176.1/jenkins.war

Replace the version with the one that fits to you.

The next step is to move that file and replace the oldest one.

# mv ./jenkins.war /usr/share/jenkins/

Then change permissions.

# chown jenkins:jenkins /usr/share/jenkins/jenkins.war

The last step is to logout from the container and restart it.

$ docker restart jenkins-docker_1

You can verify that update was successful by access to you Jenkins url.

@hbekkouche
Copy link

@ashkanyo If you can't use wget inside the docker container just use curl
curl -o jenkins.war https://ftp.halifax.rwth-aachen.de/jenkins/war-stable/2.375.3/jenkins.war

@mehreenverma20
Copy link

I don’t know it’s showing me command not found
What can be the problem am not getting

@naitbrahim
Copy link

@mehreenverma20 if you can't find the command in a docker container, don't worry, you can just install it via apt-get install wget .

@cesar-rodriguezg
Copy link

thank you!

@LarsLarsonIO
Copy link

For everyone who has issues with WGET inside the docker container. Update and Upgrade the Container like a normal Linux OS. In this case use apt update && apt upgrade and then install with apt install wget. This should fix problem.

@vl-tech
Copy link

vl-tech commented Feb 17, 2024

Thank you! Worked great!

@radhe-kishan
Copy link

thank you.

@rizkyhaksono
Copy link

thanks

@Vincenius
Copy link

If you've used docker-compose to create your Jenkins container, you can also use the following commands to update the container:

docker-compose stop
docker-compose rm -f
docker-compose pull
docker-compose up -d

@blaudroid
Copy link

If you've used docker-compose to create your Jenkins container, you can also use the following commands to update the container:

docker-compose stop
docker-compose rm -f
docker-compose pull
docker-compose up -d

this helped me, thanks!

@rigomate
Copy link

rigomate commented Nov 16, 2024

I am surprised by this. I thought modification inside a container were not persistent.
Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment