标签:png ati epo 学习 一起 替换 它的 nod swarm
docker集群部署:第5部分:堆栈#cat docker-compose.yml
services:
web:
#replace username/repo:tag with your name and image details
image: friendlyhello:latest
deploy:
replicas: 5
restart_policy:
condition: on-failure
ports:
- "80:80"
networks:
- webnet
visualizer:
image: dockersamples/visualizer:stable
ports:
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
placement:
constraints: [node.role == manager]
networks:
- webnet
networks:
webnet:
这里新增的唯一东西就是网络对等服务,名为可视化工具。在这里看到两件新事物:一个是卷密钥,赋予可视化器访问Docker的主机套接字文件的权限,另一个是放置密钥,确保此服务只能在群集管理器上运行,不会在从机上运行。
在管理器上重新运行docker stack deploy命令,任何需要更新的服务都将被更新:
#docker stack deploy -c docker-compose.yml getstartedlab
Creating network getstartedlab_webnet
Creating service getstartedlab_visualizer
Creating service getstartedlab_web
执行:
#docker stack ps getstartedlab
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
sx2vzeq6arsa getstartedlab_visualizer.1 dockersamples/visualizer:stable swarm1 Running Running 21 seconds ago
5atk91uju2sr getstartedlab_web.1 friendlyhello:latest swarm2 Running Running 23 seconds ago
8cklhjg8f69w getstartedlab_web.2 friendlyhello:latest swarm2 Running Running 23 seconds ago
aakf7bu9svwf getstartedlab_web.3 friendlyhello:latest swarm1 Running Running 23 seconds ago
w3qfs8mmrhz9 getstartedlab_web.4 friendlyhello:latest swarm2 Running Running 23 seconds ago
d8mkbmrm8pr5 getstartedlab_web.5 friendlyhello:latest swarm1 Running Running 22 seconds ago
截图如下:
标签:png ati epo 学习 一起 替换 它的 nod swarm
原文地址:http://blog.51cto.com/wutengfei/2064137