部署app service
- 编写docker-compose.yml 文件
eg:
version: "3"
services:
web:
image: username/repository:tag
deploy:
replicas: 5 几个副本
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "80:80"
networks:
- webnet
networks:
webnet:
初始化一下swarm
docker swarm init开始部署app 最后一个是app name
docker stack deloy -c docker-compose.yml getstartedlab查看容器下启动的app
docker stack ps getstartedlab关闭stack
docker stack rm getstartedlab
缩放app
修改 replicas 参数 后需要重新部署,不需要把stack关闭或者删除容器 重新部署命名参考3