github.com/kobeld/docker@v1.12.0-rc1/docs/swarm/swarm-tutorial/scale-service.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Scale the service" 4 description = "Scale the service running in the Swarm" 5 keywords = ["tutorial, cluster management, swarm, scale"] 6 [menu.main] 7 identifier="swarm-tutorial-scale-service" 8 parent="swarm-tutorial" 9 weight=18 10 advisory = "rc" 11 +++ 12 <![end-metadata]--> 13 14 # Scale the service in the Swarm 15 16 Once you have [deployed a service](deploy-service.md) to a Swarm, you are ready 17 to use the Docker CLI to scale the number of service tasks in 18 the Swarm. 19 20 1. If you haven't already, open a terminal and ssh into the machine where you 21 run your manager node. For example, the tutorial uses a machine named 22 `manager1`. 23 24 2. Run the following command to change the desired state of the 25 service runing in the Swarm: 26 27 ```bash 28 $ docker service update --replicas <NUMBER-OF-TASKS> <SERVICE-ID> 29 ``` 30 31 The `--replicas` flag indicates the number of tasks you want in the new 32 desired state. For example: 33 34 ```bash 35 $ docker service update --replicas 5 helloworld 36 helloworld 37 ``` 38 39 3. Run `docker service tasks <SERVICE-ID>` to see the updated task list: 40 41 ``` 42 $ docker service tasks helloworld 43 44 ID NAME SERVICE IMAGE DESIRED STATE LAST STATE NODE 45 1n6wif51j0w840udalgw6hphg helloworld.1 helloworld alpine RUNNING RUNNING 2 minutes manager1 46 dfhsosk00wxfb7j0cazp3fmhy helloworld.2 helloworld alpine RUNNING RUNNING 15 seconds worker2 47 6cbedbeywo076zn54fnwc667a helloworld.3 helloworld alpine RUNNING RUNNING 15 seconds worker1 48 7w80cafrry7asls96lm2tmwkz helloworld.4 helloworld alpine RUNNING RUNNING 10 seconds worker1 49 bn67kh76crn6du22ve2enqg5j helloworld.5 helloworld alpine RUNNING RUNNING 10 seconds manager1 50 ``` 51 52 You can see that Swarm has created 4 new tasks to scale to a total of 5 53 running instances of Alpine Linux. The tasks are distributed between the 54 three nodes of the Swarm. Two are running on `manager1`. 55 56 4. Run `docker ps` to see the containers running on the node where you're 57 connected. The following example shows the tasks running on `manager1`: 58 59 ``` 60 $ docker ps 61 62 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 63 910669d5e188 alpine:latest "ping docker.com" 10 seconds ago Up 10 seconds helloworld.5.bn67kh76crn6du22ve2enqg5j 64 a0b6c02868ca alpine:latest "ping docker.com" 2 minutes ago Up 2 minutes helloworld.1.1n6wif51j0w840udalgw6hphg 65 ``` 66 67 If you want to see the containers running on other nodes, you can ssh into 68 those nodes and run the `docker ps` command. 69 70 ## What's next? 71 72 At this point in the tutorial, you're finished with the `helloworld` service. 73 The next step shows how to [delete the service](delete-service.md). 74 75 <p style="margin-bottom:300px"> </p>