Commands: create Create a new service inspect Display detailed information on one or more services logs Fetch the logs of a service or task ls List services ps List the tasks of one or more services rm Remove one or more services rollback Revert changes to a service's configuration scale Scale one or multiple replicated services update Update a service Run 'docker service COMMAND --help' for more information on a command
1
docker service create --name demo busybox /bin/sh -c "while true; do sleep 3600; done"
查看容器详细信息
1 2 3
docker service ls docker service ps demo //查看service存放在哪台机器 docker ps //查看当前机器下的service
replicated表明可以横向扩展
1
docker service scale demo=5
5/5表示5个都已经ready/共5个scale
swarm 分布情况
删除swarm
1
docker service rm demo
在docker swarm下部署wordpress
1 2 3 4 5 6 7 8 9 10 11
//创建overlay网络 [vagrant@swarm-manager ~]$ docker network create -d overlay demo lqem7ybsxvsqupsamhs7gwuym [vagrant@swarm-manager ~]$ docker network ls NETWORK ID NAME DRIVER SCOPE 81117831f35e bridge bridge local lqem7ybsxvsq demo overlay swarm f5cf7cd988bf docker_gwbridge bridge local 6fca47e6833e host host local qn8r5p813ae9 ingress overlay swarm 5d8be2887f8b none null local
创建mysql service
1
docker service create --name mysql --env MYSQL_ROOT_PASSWORD=root --env MYSQL_DATABASE=wordpress --network demo --mount type=volume,source=mysql-data,destination=/var/lib/mysql mysql:5.7