gpt4 book ai didi

docker - 滚动更新后如何删除关闭的 Docker 服务任务?

转载 作者:IT老高 更新时间:2023-10-28 12:43:57 25 4
gpt4 key购买 nike

我正在使用 Docker Swarm 在 AWS 上测试服务。我最近对服务应用了这样的更新:

 docker service update --image TestImage:v2 --update-parallelism 2 \
--update-delay 10s TestService2

更新按预期工作,服务将任务容器更新到 v2。然而,一个快速的 docker service ps TestService2 | grep "v1" 显示了一堆关闭 TestImage:v1 任务。

a0w77kj0k6jfg4r9g4nz47zzg   \_ TestService2.1   TestImage:v1  W1  Shutdown       Shutdown 36 minutes ago
2of4mc63ekzbib01w3x7q6sdm \_ TestService2.2 TestImage:v1 W2 Shutdown Shutdown 37 minutes ago
495frrpza5pxt205o1594x54a \_ TestService2.3 TestImage:v1 W1 Shutdown Shutdown 36 minutes ago
57l0gsqd26u2e5gdj30w8mcn9 \_ TestService2.4 TestImage:v1 M1 Shutdown Shutdown 36 minutes ago
baoe1i79fswb34ydwbpafg6tm \_ TestService2.5 TestImage:v1 M3 Shutdown Shutdown 35 minutes ago
3uxi7kwxb73z69km6s17son58 \_ TestService2.6 TestImage:v1 M2 Shutdown Shutdown 37 minutes ago
99cg4arnt1y52nd8d422bdu49 \_ TestService2.7 TestImage:v1 M3 Shutdown Shutdown 36 minutes ago
cq5716jqp40h6jugo1j9ilzwp \_ TestService2.8 TestImage:v1 M1 Shutdown Shutdown 35 minutes ago
awlz1kxbrjk51dey7frm14d8u \_ TestService2.9 TestImage:v1 W3 Shutdown Shutdown 35 minutes ago
4xdi9a1jweyehfqlt76uynf3i \_ TestService2.10 TestImage:v1 M2 Shutdown Shutdown 36 minutes ago
eo4t6i0gaj5i294fcdnb3qncq \_ TestService2.11 TestImage:v1 W3 Shutdown Shutdown 35 minutes ago
3ydeuxdjquulv5xj94b9ovuwu \_ TestService2.12 TestImage:v1 W1 Shutdown Shutdown 36 minutes ago

如何在不转到每个单独的 swarm 节点并在退出的容器上运行 docker rm 的情况下删除这些?我认为没有 docker service 命令可以执行此操作,我查看了文档,但有谁知道我可以在 Swarm Manager 上运行以清理节点?

谢谢!

最佳答案

这些服务的容器在滚动更新后被移除;你只是留下了那些被关闭的日志。

您可以限制使用的数量

docker swarm update --task-history-limit 5 

关于docker - 滚动更新后如何删除关闭的 Docker 服务任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41705134/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com