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

我目前在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中,即使服务设置未更改,也可以通过指定 – 强制标志,容器将重新启动.如果你不介意使用1.13.0 RC4,你现在可以做到.

$docker service update --force mycontainers

更新:Docker 1.13.0已经发布.

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

相关文章
相关标签/搜索