Why jobs and system config were lost when run an image commited from a running jenkins container?
I started a jenkins container from the official jenkins image and added some plugins like git. Also, I made some basic configurations like authentication settings and user registration, then I added a jenkins job and it worked quite well in the running jenkins container.
Question is when I commited this jenkins container as a new version of jenkins image and re-ran the new image, everything was lost: no plugins added, no user registered, no jenkins job created.
Does anyone can help me to make a new jenkins image with all my configurations added? Thank you all.
2 Solutions collect form web for “Why jobs and system config were lost when run an image commited from a running jenkins container?”
you have to backup your data before rerun jenkins image:
docker cp jenkins-dv:/var/jenkins_home /tmp/jenkins-backup
also you can check this very helpful tutoriel DOCKER & JENKINS: DATA THAT PERSISTS explain HOST MOUNTED VOLUMES and DATA VOLUME CONTAINERS
Dockerfile of Jenkins defines a 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
Per default Docker manages this volume on a per container base. If you would like to use same data as in your old image/container version you have mainly two options:
Give volume a name at run
docker run -v jenkinshome:/var/jenkins_home jenkins
or map it to a volume on host system:
docker run -v /some/dir/jenkinshome:/var/jenkins_home jenkins
This way data will persist image upgrades. You can read more about managing data at official Docker documentation.