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 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.
© 2017 Docker, Inc.
Licensed under the Apache License, Version 2.0.
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.
Docker, Inc. and other parties may also have trademark rights in other terms used herein.
https://docs.docker.com/v1.13/engine/swarm/swarm-tutorial/deploy-service/