$ docker service ls ID NAME MODE REPLICAS IMAGE PORTS kv6p22irsbds hello_web replicated 5/5 friendlyhello:latest *:4000->80/tcp
#or $ docker stack services hello ID NAME MODE REPLICAS IMAGE PORTS kv6p22irsbds hello_web replicated 5/5 friendlyhello:latest *:4000->80/tcp
使用以下命令可以获得各个实例的信息
1 2 3 4 5 6 7
$ docker stack ps hello ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS g77x3nxbyeim hello_web.1 friendlyhello:latest pc Running Running 25 minutes ago a329cldr272o hello_web.2 friendlyhello:latest pc Running Running 25 minutes ago zr8putqyx4nd hello_web.3 friendlyhello:latest pc Running Running 25 minutes ago x7cun5z3kuu3 hello_web.4 friendlyhello:latest pc Running Running 25 minutes ago kc5lb0ni8y5k hello_web.5 friendlyhello:latest pc Running Running 25 minutes ago
拓展应用程序
docker支持即时更新部署,可以在运行时更新应用程序而无需停止服务,更新语句与运行语句一致
1
docker stack deploy -c docker-compose.yml hello
关闭应用程序
1 2
docker stack rm hello docker swarm leave --force
相关命令
1 2 3 4 5 6 7 8
docker stack ls # List stacks or apps docker stack deploy -c <composefile> <appname> # Run the specified Compose file docker service ls # List running services associated with an app docker service ps <service> # List tasks associated with an app docker inspect <task or container> # Inspect task or container docker container ls -q # List container IDs docker stack rm <appname> # Tear down an application docker swarm leave --force # Take down a single node swarm from the manager