Backing Up Jenkins with Docker and Pushing the Image to Artifactory
This guide explains how to install Jenkins in Docker, back up its configuration by saving the Docker image, map host directories for backups, and upload the resulting image to an Artifactory Docker registry for secure storage and easy restoration.
To simplify Jenkins backup, the article suggests running Jenkins inside Docker and periodically saving the Docker image, then uploading it to Artifactory.
Install Docker Jenkins
Download the LTS version from the Jenkins website and pull the image:
# Download specific LTS version 2.130
sudo docker pull jenkins/jenkins:2.130 # Run the Docker Jenkins
sudo docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:2.130For the latest LTS version, use:
sudo docker pull jenkins/jenkins:lts sudo docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:ltsAfter starting, access Jenkins at http://hostname:8080/.
Change Login Password
List Docker images and containers, then enter the running container to retrieve the initial admin password:
sudo docker image list sudo docker ps sudo docker exec -it 39bc7a8307d9 /bin/bash cat /var/jenkins_home/secrets/initialAdminPasswordCommit the container after changing the password:
sudo docker commit 39bc7a8307d9 myjenkins:v0.1Mount Host Directory into Docker
Run Docker with a volume to map a host directory for backups:
sudo docker run -p 8080:8080 -p 50000:50000 --name mydata -v /data/backup:/home/backup jenkins/jenkins:2.130Verify backup files inside the container.
Upload Image to Artifactory
Configure Docker to trust the Artifactory registry, log in, tag the image, and push it:
{ "insecure-registries": ["dln.dev.mycompany.com:8040"] } sudo docker login dln.dev.mycompany.com:8040 sudo docker tag myjenkins:v0.1 dln.dev.mycompany.com:8040/docker-local/myjenkins:v0.1 sudo docker push dln.dev.mycompany.com:8040/docker-local/myjenkins:v0.1The push output shows the image layers being uploaded and the image becoming available in the Artifactory Docker repository.
DevOps Engineer
DevOps engineer, Pythonista and FOSS contributor. Created cpp-linter, commit-check, etc.; contributed to PyPA.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.