Docker远程API是否具有与“ docker run --rm ...”等效的东西? [英] Does the Docker remote API have an equivalent for "docker run --rm ..."?

查看:98
本文介绍了Docker远程API是否具有与“ docker run --rm ...”等效的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在容器退出后轻松清理它们。远程API是否可以实现? (除了自己发现出口并使用DELETE / containers端点删除之外)

I'd like to be able to easily clean up containers after they exit. Is this possible with the remote API? (Other than discovering the exit myself and removing with the DELETE/containers endpoint)

推荐答案

- Docker客户端中的rm 选项完全是一个客户端选项。例如,这就是为什么不能将 -d -rm 结合的原因-因为客户端是

The --rm option in the Docker client is entirely a client side option. This is, for example, why you can't combine -d with --rm -- because the client is only able to remove the container on exit if it stays attached to the container.

您只能编写一个清理脚本,该脚本会定期运行 docker ps -f status =退出-q 并清理结果。

You could write a clean up script that would periodically run docker ps -f status=exited -q and clean up the result.

您还可以通过监视Docker API的<$ c来实现更自动化的操作。 $ c> / events 端点并立即响应容器出口。

You could also achieve something more automated by monitoring the Docker API's /events endpoint and responding immediately to container exits, I guess.

这篇关于Docker远程API是否具有与“ docker run --rm ...”等效的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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