docker-compose文件
编辑docker-compose文件,从github下载下来。
这个配置文件里面装了一个可视化的配置工具visualizer:stable 可以查看到docker-swarm 所有的节点信息。
cd labs/cd example-vote-app/ more docker-compose.yml
compose的语法
version: "3"services: redis: image: redis:alpine ports: - "6379" networks: - frontend deploy: replicas: 2 update_config: parallelism: 2 delay: 10s restart_policy: condition: on-failure db: image: postgres:9.4 volumes: - db-data:/var/lib/postgresql/data networks: - backend deploy: placement: constraints: [node.role == manager] vote: image: dockersamples/examplevotingapp_vote:before ports: - 5000:80 networks: - frontend depends_on: - redis deploy: replicas: 2 update_config: parallelism: 2 restart_policy: condition: on-failure result: image: dockersamples/examplevotingapp_result:before ports: - 5001:80 networks: - backend depends_on: - db deploy: replicas: 1 update_config: parallelism: 2 delay: 10s restart_policy: condition: on-failure worker: image: dockersamples/examplevotingapp_worker networks: - frontend - backend deploy: mode: replicated replicas: 1 labels: [APP=VOTING] restart_policy: condition: on-failure delay: 10s max_attempts: 3 window: 120s placement: constraints: [node.role == manager] visualizer: image: dockersamples/visualizer:stable ports: - "8080:8080" stop_grace_period: 1m30s volumes: - "/var/run/docker.sock:/var/run/docker.sock" deploy: placement: constraints: [node.role == manager] networks: frontend: backend: volumes: db-data:
投票docker-stack 部署
docker stack deploy example --compose-file=docker-compose.yml docker stack ls docker stack services example
打开网页
http://172.28.128.3:5000/
http://172.28.128.3:5001/
http://172.28.128.3:8080/
扩展vote
docker service scale example_vote=4
删除stack
docker stack rm example
PS:docker stack 就介绍到这里吧,其实最关键的是编写docker-compose.yml查看官网的学习方式。对于本次编写的一些关键字建议看看官网学习下。
作者:IT人故事会
链接:https://www.jianshu.com/p/74e05190473f
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦