Deploy a service to the swarm
Docker Docs · نسخهٔ 747e4c7528c7 · CC BY 4.0 برای مستندات و مجوزهای همراه
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:
console
$ docker service create --replicas 1 --name helloworld alpine ping docker.com
9uk4639qpg7npwf3fn2aasksr- The
docker service createcommand creates the service. - The
--nameflag names the servicehelloworld. - The
--replicasflag specifies the desired state of 1 running instance. - The arguments
alpine ping docker.comdefine the service as an Alpine
Linux container that executes the command ping docker.com.
- Run
docker service lsto see the list of running services:
console
$ docker service ls
ID NAME SCALE IMAGE COMMAND
9uk4639qpg7n helloworld 1/1 alpine ping docker.comNext steps
Now you're ready to inspect the service.
{{< button text="Inspect the service" url="inspect-service.md" >}}