目前,我的 docker 设置中有 8 个容器跨 4 台不同的主机。
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 重新启动所有容器?我不想手动登录每个节点并执行重新启动。
Best Answer-推荐答案
在最新的稳定版docker 1.12.x中,可以通过更新服务配置来重启容器,但是在即将发布的docker 1.13.0中,即使服务设置没有改变,通过指定--force 标志,容器将重新启动。如果您不介意使用 1.13.0 RC4,您现在可以使用。
$ docker service update --force mycontainers
更新ocker 1.13.0 已经发布。
https://github.com/docker/docker/releases/tag/v1.13.0
关于docker - 如何在 docker swarm 中重启多个容器,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/41388183/
|