Signed-off-by: Charles Smith <charles.smith@docker.com> Upstream-commit: ea4fef2d875de39044ca7570c35365b75086e8a5 Component: engine
1.5 KiB
1.5 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 --scale 1 --name helloworld alpine ping docker.com 2zs4helqu64f3k3iuwywbk49w- The
docker service createcommand creates the service. - The
--nameflag names the servicehelloworld. - The
--scaleflag specifies the desired state of 1 running instance. - The arguments
alpine ping docker.comdefine the service as an Alpine Linux container that executes the commandping docker.com.
- The
-
Run
docker service lsto see the list of running services:$ docker service ls ID NAME SCALE IMAGE COMMAND 2zs4helqu64f helloworld 1 alpine ping docker.com
What's next?
Now you've deployed a service to the Swarm, you're ready to inspect the service.