docker swarm init --advertise-addr <MANAGER-IP>
$ docker info Containers: 2 Running: 0 Paused: 0 Stopped: 2 ..snip... Swarm: active NodeID: dxn1zf6l61qsb1josjja83ngz Is Manager: true Managers: 1 Nodes: 1 ...snip...
[root@centos5 ~]# docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ip2fs5kkfpllyexal8pxuxnlq centos4 Ready Active t7998hft3zw479evc7lr8irx2 * centos5 Ready Active Leade
docker swarm join-token worker [root@centos5 ~]# docker swarm join-token worker To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-1705vcetk9pgd3nb9zph2izwtcudq1ajeh7b13wqcst46epk18-bltg74jq3ql7zrswirt6xhwm3 10.173.38.40:2377
docker service create --replicas 1 --name helloworld alpine ping docker.com
[root@centos5 ~]# docker service inspect --pretty helloworld ID: vk639rdtes0pw8anp7dxnznzu Name: helloworld Service Mode: Replicated Replicas: 1 Placement: UpdateConfig: Parallelism: 1 On failure: pause Monitoring Period: 5s Max failure ratio: 0 Update order: stop-first RollbackConfig: Parallelism: 1 On failure: pause Monitoring Period: 5s Max failure ratio: 0 Rollback order: stop-first ContainerSpec: Image: alpine:latest@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe Args: ping docker.com Resources: Endpoint Mode: vip
[root@centos5 ~]# docker service ps helloworld ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS zgeljyk5fqf6 helloworld.1 alpine:latest centos5 Running Running 8 minutes ago
*Run the following command to change the desired state of the service running in the swarm:node
$ docker service scale <SERVICE-ID>=<NUMBER-OF-TASKS>
docker service update --image redis:3.0.7 redis