Why were jobs and system configuration lost when running an image retrieved from a running jenkins container?

I started the jenkins container from the official jenkins image and added some plugins like git. In addition, I made some basic configurations, such as authentication and user registration settings, and then added jenkins to work, and it worked pretty well in a running jenkins container. The question is, when I launched this jenkins container as a new version of the jenkins image and re-launched the new image, everything was lost: no added plugins, no registered users, jenkins jobs were created. Can anyone help me create a new jenkins image with all my configurations? Thanks to everyone.

Regards, Yuliang

+4
source share
2 answers

you need to backup your data before playing the jenkins image:

docker cp jenkins-dv:/var/jenkins_home /tmp/jenkins-backup

Alternatively, you can check out this very useful tutoriel DOCKER and JENKINS: DATA WHICH PROVIDE TO EXPLAIN HOST MOUNTED VOLUMES and DATA VOLUME CONTAINERS

+3
source

Dockerfile Jenkins defines the volume for its home directory:

# Jenkins home directory is a volume, so configuration and build history 
# can be persisted and survive image upgrades
VOLUME /var/jenkins_home

By default, Docker manages this volume based on each container. If you want to use the same data as in your old version of image / container, you have basically two options:

Give the volume a name at startup

docker run -v jenkinshome:/var/jenkins_home jenkins

or map it to a volume in the main system:

docker run -v /some/dir/jenkinshome:/var/jenkins_home jenkins

, . Docker.

0

All Articles