Docker 17
引擎 | Engine

部署服务(引擎) | Deploy a service (Engine)

Deploy a service to the swarm

创建完群后,您可以将服务部署到群中。在本教程中,您还添加了工作节点,但这不是部署服务的必要条件。

  • 打开终端并将ssh放入运行管理器节点的机器中。例如,本教程使用名为的计算机manager1

  • 运行以下命令:

$ 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`.

  • 运行docker service ls以查看正在运行的服务的列表:

$ docker service ls ID NAME SCALE IMAGE COMMAND 9uk4639qpg7n helloworld 1/1 alpine ping docker.com

下一步是什么?

现在您已经为群组部署了一项服务,您已准备好检查该服务。

教程集群管理群集模式