Docker 简明教程

Docker - Continuous Integration

Docker 已与许多持续集成工具集成,其中也包括作为 Jenkins 而闻名的流行 CI 工具。在 Jenkins 中,您有可用于处理容器的可用插件。因此,让我们快速了解适用于 Jenkins 工具的 Docker 插件。

Docker has integrations with many Continuous Integrations tools, which also includes the popular CI tool known as Jenkins. Within Jenkins, you have plugins available which can be used to work with containers. So let’s quickly look at a Docker plugin available for the Jenkins tool.

让我们逐步了解 Jenkins 中 Docker 容器的可用功能。

Let’s go step by step and see what’s available in Jenkins for Docker containers.

Step 1 − 转到 Jenkins 仪表板,然后单击 Manage Jenkins

Step 1 − Go to your Jenkins dashboard and click Manage Jenkins.

manage jenkins

Step 2 − 转到 Manage Plugins

Step 2 − Go to Manage Plugins.

manage pluggins

Step 3 - 搜索 Docker 插件。选择 Docker 插件并单击 Install without restart 按钮。

Step 3 − Search for Docker plugins. Choose the Docker plugin and click the Install without restart button.

install without restart

Step 4 - 安装完成后,转到 Jenkins 仪表板中的作业。在我们的示例中,我们有一个名为 Demo 的作业。

Step 4 − Once the installation is completed, go to your job in the Jenkins dashboard. In our example, we have a job called Demo.

demo

Step 5 - 在作业中,转到构建步骤后,你现在可以看到启动和停止容器的选项。

Step 5 − In the job, when you go to the Build step, you can now see the option to start and stop containers.

add build step

Step 6 - 作为简单示例,你可以选择在构建完成后停止容器的选项。然后,单击 Save 按钮。

Step 6 − As a simple example, you can choose the further option to stop containers when the build is completed. Then, click the Save button.

stop all containers

现在,只需在 Jenkins 中运行你的作业。在控制台输出中,你现在可以看到用于停止所有容器的命令已经运行。

Now, just run your job in Jenkins. In the Console output, you will now be able to see that the command to Stop All containers has run.

console output