Reputation: 2062
I made a docker pull jenkins:latest
then I ran the container: docker run --name jenk -p 8080:8080 jenkins
I set up all the jobs, configurations, etc within jenkins. Afterwards I committed the change:
docker commit jenk myrepo/jenkins
when I now pull the image and start it: docker run myrepo/jenkins
all the configuration is lost. I thought it would preserve it.
Upvotes: 1
Views: 497
Reputation: 51876
As described in the docker commit documentation:
The commit operation will not include any data contained in volumes mounted inside the container.
The jenkins image declared the jenkins home as a volume VOLUME /var/jenkins_home
. The volume container all the configuration and jobs created. Thus when you commit the container, all this configuration willnot be persisted in the
commited image.
If you are running the new image on the same machine, you can use the jenkins_home volume from the older container and get exactly the same jenkins instance:
docker volume ls //To determine the old container volume name
docker run -v <old-volume-name>:/var/jenkins_home -p 8080:8080 myrepo/jenkins
If you are running the commited intance on a new machine:
docker cp <old-container>:/var/jenkins_home ./jenkins_home
Now copy the jenkins_home folder onto the new machine, and mount it onto the new container:
docker run -v ./jenkins_home:/var/jenkins_home -p 8080:8080 myrepo/jenkins
Upvotes: 1
Reputation: 2731
You also need to push it to your (remote) repository before you can pull it again. The commit only saves the state to your local drive. A pull always goes to a repository.
Some free advice:
Dockerfile
though, by extending the jenkins:latest and adding your own changes to it. This makes it much more maintainable and changeable.Question:
Did you do this all inside the image or also on mounted volumes? according to the documentation those settings will not be included
The commit operation will not include any data contained in volumes mounted inside the container.
Have fun :-)
Upvotes: 1