简体   繁体   English

詹金斯与码头工人

[英]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? 如何使用docker的图像并将更改保存在容器中?

When you commit an image it does not inherit the CMD from its parent image. 提交映像时,它不会从其父映像继承CMD。 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. Jenkins将其配置存储在目录中,例如/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, 在这种情况下,请在提交容器时使用-run选项以指定新配置,

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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