github.com/portworx/docker@v1.12.1/docs/swarm/swarm-tutorial/deploy-service.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Deploy a service" 4 description = "Deploy a service to the swarm" 5 keywords = ["tutorial, cluster management, swarm mode"] 6 [menu.main] 7 identifier="deploy-application" 8 parent="swarm-tutorial" 9 weight=16 10 +++ 11 <![end-metadata]--> 12 13 # Deploy a service to the swarm 14 15 After you [create a swarm](create-swarm.md), you can deploy a service to the 16 swarm. For this tutorial, you also [added worker nodes](add-nodes.md), but that 17 is not a requirement to deploy a service. 18 19 1. Open a terminal and ssh into the machine where you run your manager node. For 20 example, the tutorial uses a machine named `manager1`. 21 22 2. Run the the following command: 23 24 ```bash 25 $ docker service create --replicas 1 --name helloworld alpine ping docker.com 26 27 9uk4639qpg7npwf3fn2aasksr 28 ``` 29 30 * The `docker service create` command creates the service. 31 * The `--name` flag names the service `helloworld`. 32 * The `--replicas` flag specifies the desired state of 1 running instance. 33 * The arguments `alpine ping docker.com` define the service as an Alpine 34 Linux container that executes the command `ping docker.com`. 35 36 3. Run `docker service ls` to see the list of running services: 37 38 ``` 39 $ docker service ls 40 41 ID NAME SCALE IMAGE COMMAND 42 9uk4639qpg7n helloworld 1/1 alpine ping docker.com 43 ``` 44 45 ## What's next? 46 47 Now you've deployed a service to the swarm, you're ready to [inspect the service](inspect-service.md).