使用Jenkins将更改部署到Docker容器 [英] Deploy changes to Docker container using Jenkins

查看:175
本文介绍了使用Jenkins将更改部署到Docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处是Docker新手.

Docker newbie here.

我已经设置了docker容器来运行一个简单的Node JS应用程序.

I have set up and docker container to run a simple Node JS application.

假设我有一个新版本的应用程序(例如 1.1 ),该版本必须由Jenkins CI进行部署.在这里,我对Jenkins CI到底应该做什么应该有所了解:

Let's say I am having a new version of my application (e.g 1.1) which has to be deployed by a Jenkins CI. Here I am getting a bit lost about what exactly the Jenkins CI should do:

  • 是否应该关闭并删除旧容器( 1.0 )并启动新实例 1.1 ?
  • Should shut down and remove the old container (1.0) and launch a the new instance 1.1?

OR

  • 是否应该进入当前正在运行的容器并仅更新代码?

推荐答案

使用CI/CD工具(如Jenkins)的理想做法如下:

The ideal practice using CI/CD tool like Jenkins is as follows:

1)在Jenkins中完成一项工作(最好是Jenkins管道工作),该工作应从您的SCM存储库中签出代码,然后对该代码运行定义的单元测试和隔离的集成测试.

1) Make a job in Jenkins(ideally a Jenkins pipeline job) that should checkout the code from your SCM repository and then run the defined unit test and isolated integration test on that code.

2)然后,该作业将根据您的代码创建映像,并对其进行正确标记并将其存储在所需的docker存储库中.

2) That job then create the image out of your code and properly tag it and store it your required docker repository.

3)然后,作业应转到您的docker主机并拉出新的docker映像,停止旧容器并随后运行新容器.

3) The job then should go to your docker host and pull the new docker image, stop the old container and run the new container afterwards.

4)作为可选步骤,您可以在运行docker容器的主机中设置cron来管理旧的孤立映像和容器.

4) As an optional step you can setup a cron in your host running the docker containers to manage the old orphaned images and containers.

这篇关于使用Jenkins将更改部署到Docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆