简体   繁体   English

从Jenkins管道运行docker容器

[英]Run docker container from Jenkins pipeline

I currently run a Jenkins instance inside a Docker container. 我目前在Docker容器中运行Jenkins实例。 I've been doing some experimenting with Jenkins and their pipelines. 我一直在对Jenkins及其管道进行一些试验。 I managed to make my Maven app build successful using a Jenkinsfile. 我设法使用Jenkinsfile使Maven应用程序构建成功。

Right now I am trying to automatically deploy the app I built to a docker container that's a sibling to the Jenkins container. 现在,我试图将我构建的应用程序自动部署到与Jenkins容器同级的docker容器中。 I did already mount the /var/run/docker.sock so I have access to the parent docker. 我已经挂载了/var/run/docker.sock,所以我可以访问父泊坞窗。 But right now I can't seem to find any good information to guide me through the next part, which is modifying the Jenkinsfile to deploy my app in a new container. 但是现在,我似乎找不到任何好的信息来指导我完成下一部分,即修改Jenkinsfile以将我的应用程序部署到新容器中。

How would I go over and run my Maven app inside a sibling docker container? 我将如何在同一个Docker容器中运行Maven应用程序?

It might be more appropriate to spin up a slave node (a physical or virtual box) and then run something in there with docker. 旋转从属节点(物理或虚拟盒子),然后使用docker在其中运行某些命令可能更合适。

If you check your instance URL: https://jenkins.address/job/myjob/pipeline-syntax/ 如果您检查实例URL: https://jenkins.address/job/myjob/pipeline-syntax/

You will find more information about what are the commands you need for this. 您将找到有关为此所需的命令的更多信息。

Anyway best way to do this is to actually create a dockerfile and as a step copy the artifact in it, push the image to a registry and then find somewhere to deploy the just built image 无论如何,执行此操作的最佳方法是实际创建一个dockerfile,并在其中复制工件,然后将映像推送到注册表,然后在某个地方部署刚刚构建的映像

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

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