gpt4 book ai didi

docker - 如何在 docker swarm 中重新启动多个容器

转载 作者:IT老高 更新时间:2023-10-28 21:34:50 26 4
gpt4 key购买 nike

我目前在我的 docker 设置中有 4 个不同主机的 8 个容器。

ubuntu@ip-192-168-1-8:~$ docker service ls
ID NAME MODE REPLICAS IMAGE
yyyytxxxxx8 mycontainers global 8/8 myapplications:latest

在服务上运行 ps -a 会产生以下结果。

ubuntu@ip-192-168-1-8:~$ docker service ps -a yy
NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
mycontainers1 myapplications:latest: ip-192-168-1-5 Running Running 3 hours ago
\_ mycontainers2 myapplications:latest: ip-192-168-1-6 Running Running 3 hours ago
\_ mycontainers3 myapplications:latest: ip-192-168-1-7 Running Running 3 hours ago
\_ mycontainers4 myapplications:latest: ip-192-168-1-8 Running Running 3 hours ago
\_ mycontainers1 myapplications:latest: ip-192-168-1-5 Running Running 3 hours ago
\_ mycontainers2 myapplications:latest: ip-192-168-1-6 Running Running 3 hours ago
\_ mycontainers3 myapplications:latest: ip-192-168-1-7 Running Running 3 hours ago
\_ mycontainers4 myapplications:latest: ip-192-168-1-8 Running Running 3 hours ago

我的问题是如何使用服务 ID 重新启动所有容器?我不想手动登录每个节点并执行重启。

最佳答案

在最新的稳定版docker 1.12.x中,可以通过更新服务配置来重启容器,但是在即将发布的docker 1.13.0中,即使服务设置没有改变,通过指定--force 标志,容器将被重新启动。如果您不介意使用 1.13.0 RC4,您现在可以使用。

$ docker service update --force mycontainers

更新:Docker 1.13.0 已经发布。

https://github.com/docker/docker/releases/tag/v1.13.0

关于docker - 如何在 docker swarm 中重新启动多个容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41388183/

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