简体   繁体   中英

Jenkins with docker

My problem is:

docker run -d -p 8080:8080 asd/jenkins # everything's ok
# made changes at jenkins
docker commit container_with_jenkins   # comitted
docker run -d -p 8080:8080 image_from_container_with_changes 
# => Error: create: No command specified

Am I missing something?
How do one work with docker's images and save changes within container?

When you commit an image it does not inherit the CMD from its parent image. So when you start a container based on the new image, you need to supply a run command.

docker run -d image_from_container_with_changes java -jar /var/lib/jenkins/jenkins.war

where the run command of course depends on your specific installation.

Jenkins stores it's configuration in a directory, eg /root/.jenkins. What I would recommend is to create a directory on the host and link this as a volume:

docker run -v {absolute_path_to_jenkins_dir}:/root/.jenkins -d asd/jenkins

If you start a new container in the same way, it will have the same jobs etc. In case you make changes that do go into this directory (I don't know by head where plugins or updates are installed) you still might want to make a new image. In that case, use the -run option when you commit your container to specify new configuration,

docker commit -run='{"Cmd": ["java", "-jar", "/var/lib/jenkins/jenkins.war"]}' abc1234d

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM