mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 053ac127ab
)
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
Conflicts:
docs/reference/api/docker_remote_api_v1.25.md
docs/reference/commandline/service_create.md
1.4 KiB
1.4 KiB
Deploy a service to the swarm
After you create a swarm, you can deploy a service to the swarm. For this tutorial, you also added worker nodes, but that is not a requirement to deploy a service.
-
Open a terminal and ssh into the machine where you run your manager node. For example, the tutorial uses a machine named
manager1
. -
Run the the following command:
$ docker service create --replicas 1 --name helloworld alpine ping docker.com 9uk4639qpg7npwf3fn2aasksr
- The
docker service create
command creates the service. - The
--name
flag names the servicehelloworld
. - The
--replicas
flag specifies the desired state of 1 running instance. - The arguments
alpine ping docker.com
define the service as an Alpine Linux container that executes the commandping docker.com
.
- The
-
Run
docker service ls
to see the list of running services:$ docker service ls ID NAME SCALE IMAGE COMMAND 9uk4639qpg7n helloworld 1/1 alpine ping docker.com
What's next?
Now you've deployed a service to the swarm, you're ready to inspect the service.