2016-06-07 17:08:36 -07:00
|
|
|
<!--[metadata]>
|
|
|
|
+++
|
|
|
|
title = "Deploy a service"
|
2016-06-15 13:26:13 -07:00
|
|
|
description = "Deploy a service to the swarm"
|
|
|
|
keywords = ["tutorial, cluster management, swarm mode"]
|
2016-06-16 11:33:12 +00:00
|
|
|
advisory = "rc"
|
2016-06-07 17:08:36 -07:00
|
|
|
[menu.main]
|
|
|
|
identifier="deploy-application"
|
|
|
|
parent="swarm-tutorial"
|
|
|
|
weight=16
|
|
|
|
+++
|
|
|
|
<![end-metadata]-->
|
|
|
|
|
2016-06-15 13:26:13 -07:00
|
|
|
# Deploy a service to the swarm
|
2016-06-07 17:08:36 -07:00
|
|
|
|
2016-06-15 13:26:13 -07:00
|
|
|
After you [create a swarm](create-swarm.md), you can deploy a service to the
|
|
|
|
swarm. For this tutorial, you also [added worker nodes](add-nodes.md), but that
|
2016-06-07 17:08:36 -07:00
|
|
|
is not a requirement to deploy a service.
|
|
|
|
|
|
|
|
1. 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 the following command:
|
|
|
|
|
|
|
|
```bash
|
2016-06-14 16:29:10 -07:00
|
|
|
$ docker service create --replicas 1 --name helloworld alpine ping docker.com
|
2016-06-07 17:08:36 -07:00
|
|
|
|
2016-06-15 13:26:13 -07:00
|
|
|
9uk4639qpg7npwf3fn2aasksr
|
2016-06-07 17:08:36 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
* The `docker service create` command creates the service.
|
|
|
|
* The `--name` flag names the service `helloworld`.
|
2016-06-14 16:29:10 -07:00
|
|
|
* The `--replicas` flag specifies the desired state of 1 running instance.
|
2016-06-07 17:08:36 -07:00
|
|
|
* The arguments `alpine ping docker.com` define the service as an Alpine
|
|
|
|
Linux container that executes the command `ping docker.com`.
|
|
|
|
|
|
|
|
3. Run `docker service ls` to see the list of running services:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ docker service ls
|
|
|
|
|
2016-06-15 13:26:13 -07:00
|
|
|
ID NAME SCALE IMAGE COMMAND
|
|
|
|
9uk4639qpg7n helloworld 1/1 alpine ping docker.com
|
2016-06-07 17:08:36 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
## What's next?
|
|
|
|
|
2016-06-15 13:26:13 -07:00
|
|
|
Now you've deployed a service to the swarm, you're ready to [inspect the service](inspect-service.md).
|
2016-06-07 17:08:36 -07:00
|
|
|
|
|
|
|
<p style="margin-bottom:300px"> </p>
|