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.

Regards,
yuliang

  • Docker Neo4j Container keeps stopping - how to debug?
  • Cannot connect via PHP to docker mysql
  • StatusCode.UNAUTHENTICATED when running Vision API demo in Python/Flask running in Docker
  • Docker inspect with unix:///var/run/docker.sock (in Java or Scala)
  • Single file volume mounted as directory in Docker
  • uWSGI + Docker: pyuwsgi: executable file not found in $PATH
  • how a host can provide service to containers?
  • Which permission does a docker named volume get upon mounting?
  • docker pull push not working post successful login
  • Referencing files inside build (Docker)
  • 'docker build' gives error that 'docker run' doesn't. How are they different?
  • Wierd Docker DNS error referencing C file?
  • 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.

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