Home Explore Blog Models CI



docker

content/manuals/engine/swarm/swarm-tutorial/deploy-service.md
6f0c96448494d4096e668c8a203577d540435b7090d9b13f0000000300000565
---
description: Deploy a service to the swarm
keywords: tutorial, cluster management, swarm mode, get started
title: Deploy a service to the swarm
weight: 30
notoc: true
---

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
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 following command:

    ```console
    $ 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 service `helloworld`.
    * 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 command `ping docker.com`.

3.  Run `docker service ls` to see the list of running services:

    ```console
    $ docker service ls

    ID            NAME        SCALE  IMAGE   COMMAND
    9uk4639qpg7n  helloworld  1/1    alpine  ping docker.com
    ```

## Next steps

Now you're ready to inspect the service.

{{< button text="Inspect the service" url="inspect-service.md" >}}

Chunks
7c5fdd83 (1st chunk of `content/manuals/engine/swarm/swarm-tutorial/deploy-service.md`)
Title: Deploying a Service to the Swarm
Summary
After creating a swarm, you can deploy a service to it. This involves SSHing into the manager node and using the `docker service create` command. The example deploys a service named 'helloworld' that runs an Alpine Linux container pinging docker.com. The `docker service ls` command can be used to view the running services. The next step is to inspect the service.