Can I move docker container that includes Jenkins setups to other server? Can I move docker container that includes Jenkins setups to other server? docker docker

Can I move docker container that includes Jenkins setups to other server?


As described in the docs for the commit command

The commit operation will not include any data contained in volumes mounted inside the container.

The jenkins home is mounted as a volume, thus when you commit the container the jenkins home won't be commited. Therefore all the job configuration that is currently on the running local container won't be part of the commited image.

Your problem reduces to how would you migrate the jenkins_home volume that is on your machine, to the another machine. This problem is solved and you can find the solution here.

I would suggest however a better and more scalable approach, specifically for jenkins. The problem with the first approach, is that there is quiet some manual intervention that needs to be done whenever you want to start a similar jenkins instance on a new machine.

The solution is as follows:

  1. Commit the container that is currently running
  2. Copy the job configuration that is inside the container using the command: docker cp /var/jenkins_home/jobs ./jobs. This will copy the job config from the running container into your machine. Remember to clean the build folders
  3. Create a Dockerfile that inherits from the commited image and copy the job config under the jenkins_home.
  4. Push the image and you should have an image that you can pull and will have all the jobs configured correctly

The dockerfile will look something like:

FROM <commited-container>COPY jobs/* /var/jenkins_home/jobs/


You need to check how the Jenkins image (hub.docker.com/r/jenkins/jenkins/) was launched on your local computer: if it was mounting a local volume, that volume should include the JENKINS_HOME with all the job configurations and plugins.

docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts

You need to export that volume too, not just the image.
See for instance "Docker & Jenkins: Data that Persists ", using a data volume container that you can then export/import.