Jenkins inside docker loses configuration when container is restarted

I have followed the next guide to download the docker image with Jenkins.

When I start my container using docker start CONTAINERNAME command, I can access to Jenkins from localhost:8080.

  • in pid 1 for address resolved by kube-dns
  • docker multiply hostnames for one container
  • Shared Docker devicemapper lvm thinpool in a multiboot setup
  • docker mongodb replication on same server
  • Docker: transaction check error
  • Dockerfile inconsistent caching
  • The problem comes up when I change Jenkins configuration and restart Jenkins using docker stop CONTAINERNAME and docker start CONTAINERNAME, my Jenkins doesn’t contain any of my previous configuration changes..

    How can I persist the Jenkins configuration?

  • Is there a straight way to get html response from a unix socket in Go (like curl does)?
  • Start full container in Docker?
  • how to set supervisor to run a shell script
  • Connect from one Docker container to another
  • Dockerfile supervisord cannot find path
  • How can I overcame this 500 Server Internal Error when trying to pull google/appengine-java image for Managed VMs?
  • One Solution collect form web for “Jenkins inside docker loses configuration when container is restarted”

    You need to mount the Jenkins configuration as a volume, the -v flag will do just that for you. (you can ignore the --privileged flag in my example unless you plan on building docker images inside your jenkins docker image)

    docker run --privileged --name='jenkins' -d -p 6999:8080 -p 50000:50000 -v /home/jan/jenkins:/var/jenkins_home jenkins:latest

    The -v flag will mount your /var/jenkins_home outside your container in /home/jan/jenkins maintaining it between rebuilds.

    --name so that you have a fixed name for the container to start / stop it from.

    Then next time you want to run it, simply call

    docker start jenkins
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.