【问题标题】:list all containers with restart policies列出所有具有重启策略的容器
【发布时间】:2023-02-04 14:50:20
【问题描述】:

是否可以列出所有设置了重启策略的 docker 容器?我可以检查正在运行的容器 (How to quickly show policies of all docker containers),但是如果一个容器之前已经停止,或者有一个失败策略并且已经成功完成怎么办?

【问题讨论】:

  • I could inspect the running containers (How to quickly show policies of all docker containers), but what if one sooo 检查所有容器不仅在运行?

标签: docker


【解决方案1】:

我可以检查正在运行的容器(How to quickly show policies of all docker containers),但是如果一个容器之前已经停止,或者有一个失败策略并且已经成功完成怎么办?

没错,所以不要停止运行容器 - 检查全部容器。

只需列出具有该策略的所有容器。

docker ps -a -q | xargs docker inspect | jq -r '.[] | select(.HostConfig.RestartPolicy.Name != "no") | .Name'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-17
    • 1970-01-01
    • 2018-12-12
    • 1970-01-01
    • 2016-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多