Jenkins作业终止后清理孤立的Docker容器 [英] Cleaning up orphaned docker containers after Jenkins job is terminated

查看:246
本文介绍了Jenkins作业终止后清理孤立的Docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个大型组织中工作,该组织在一个共享的Jenkins集群中运行数百个工作.

I work at a large organization that runs hundreds of jobs in a shared Jenkins cluster.

我的Jenkins工作需要针对在Docker容器中运行的不受信任的代码运行集成测试.我担心当我的詹金斯(Jenkins)工作突然终止(例如工作中止或超时)时,我会留下孤零零的容器.

My Jenkins job needs to run integration tests against untrusted code running inside Docker containers. I am fearful that that when my Jenkins job gets terminated abruptly (e.g. job aborted or times out) I will be left with orphaned containers.

我尝试了 https://github.com/moby/moby/issues/1905 ulimits对我不起作用(这是因为它仅适用于运行bash 的容器,我不能保证我会这样做.

I have tried https://github.com/moby/moby/issues/1905 and ulimits does not work for me (this is because it only works for containers that run bash, and I cannot guarantee that mine will do so).

我尝试了 https://stackoverflow.com/a/26351355/14731 ,但是--lxc-conf无法识别Windows的Docker选项(这需要在docker支持的所有平台上运行).

I tried https://stackoverflow.com/a/26351355/14731 but --lxc-conf is not a recognized option for Docker for Windows (this needs to run across all platforms supported by docker).

有什么想法吗?

推荐答案

从事物的外观来看,人们正在docker外部进行处理.

By the looks of things, people are handling this outside of docker.

他们正在添加Jenkins的构建后步骤,以清理中止或失败的构建上的孤立Docker容器.

They are adding Jenkins post-build steps that clean up orphaned docker containers on aborted or failed builds.

请参阅Martin Kenneth的

See Martin Kenneth's build script as an example.

这篇关于Jenkins作业终止后清理孤立的Docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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