mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
![Stephen J Day](/assets/img/avatar_default.png)
Rather than conflict with the unexposed task model, change the names of the object-oriented task display to `docker <object> ps`. The command works identically to `docker service tasks`. This change is superficial. This provides a more sensical docker experience while not trampling on the task model that may be introduced as a top-level command at a later date. The following is an example of the display using `docker service ps` with a service named `condescending_cori`: ``` $ docker service ps condescending_cori ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE e2cd9vqb62qjk38lw65uoffd2 condescending_cori.1 condescending_cori alpine Running 13 minutes ago Running 6c6d232a5d0e ``` The following shows the output for the node on which the command is running: ```console $ docker node ps self ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE b1tpbi43k1ibevg2e94bmqo0s mad_kalam.1 mad_kalam apline Accepted 2 seconds ago Accepted 6c6d232a5d0e e2cd9vqb62qjk38lw65uoffd2 condescending_cori.1 condescending_cori alpine Running 12 minutes ago Running 6c6d232a5d0e 4x609m5o0qyn0kgpzvf0ad8x5 furious_davinci.1 furious_davinci redis Running 32 minutes ago Running 6c6d232a5d0e ``` Signed-off-by: Stephen J Day <stephen.day@docker.com>
71 lines
2.6 KiB
Markdown
71 lines
2.6 KiB
Markdown
<!--[metadata]>
|
|
+++
|
|
title = "Scale the service"
|
|
description = "Scale the service running in the swarm"
|
|
keywords = ["tutorial, cluster management, swarm mode, scale"]
|
|
[menu.main]
|
|
identifier="swarm-tutorial-scale-service"
|
|
parent="swarm-tutorial"
|
|
weight=18
|
|
+++
|
|
<![end-metadata]-->
|
|
|
|
# Scale the service in the swarm
|
|
|
|
Once you have [deployed a service](deploy-service.md) to a swarm, you are ready
|
|
to use the Docker CLI to scale the number of service ps in
|
|
the swarm.
|
|
|
|
1. If you haven't already, open a terminal and ssh into the machine where you
|
|
run your manager node. For example, the tutorial uses a machine named
|
|
`manager1`.
|
|
|
|
2. Run the following command to change the desired state of the
|
|
service running in the swarm:
|
|
|
|
```bash
|
|
$ docker service scale <SERVICE-ID>=<NUMBER-OF-TASKS>
|
|
```
|
|
|
|
For example:
|
|
|
|
```bash
|
|
$ docker service scale helloworld=5
|
|
|
|
helloworld scaled to 5
|
|
```
|
|
|
|
3. Run `docker service ps <SERVICE-ID>` to see the updated task list:
|
|
|
|
```
|
|
$ docker service ps helloworld
|
|
|
|
ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE
|
|
8p1vev3fq5zm0mi8g0as41w35 helloworld.1 helloworld alpine Running 7 minutes Running worker2
|
|
c7a7tcdq5s0uk3qr88mf8xco6 helloworld.2 helloworld alpine Running 24 seconds Running worker1
|
|
6crl09vdcalvtfehfh69ogfb1 helloworld.3 helloworld alpine Running 24 seconds Running worker1
|
|
auky6trawmdlcne8ad8phb0f1 helloworld.4 helloworld alpine Running 24 seconds Accepted manager1
|
|
ba19kca06l18zujfwxyc5lkyn helloworld.5 helloworld alpine Running 24 seconds Running worker2
|
|
```
|
|
|
|
You can see that swarm has created 4 new tasks to scale to a total of 5
|
|
running instances of Alpine Linux. The tasks are distributed between the
|
|
three nodes of the swarm. One is running on `manager1`.
|
|
|
|
4. Run `docker ps` to see the containers running on the node where you're
|
|
connected. The following example shows the tasks running on `manager1`:
|
|
|
|
```
|
|
$ docker ps
|
|
|
|
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
|
528d68040f95 alpine:latest "ping docker.com" About a minute ago Up About a minute helloworld.4.auky6trawmdlcne8ad8phb0f1
|
|
```
|
|
|
|
If you want to see the containers running on other nodes, you can ssh into
|
|
those nodes and run the `docker ps` command.
|
|
|
|
## What's next?
|
|
|
|
At this point in the tutorial, you're finished with the `helloworld` service.
|
|
The next step shows how to [delete the service](delete-service.md).
|