?
This document uses PHP Chinese website manual Release
創(chuàng)建完群后,您可以將服務(wù)部署到群中。在本教程中,您還添加了工作節(jié)點(diǎn),但這不是部署服務(wù)的必要條件。
打開終端并將ssh放入運(yùn)行管理器節(jié)點(diǎn)的機(jī)器中。例如,本教程使用名為的計(jì)算機(jī)manager1
。
運(yùn)行以下命令:
$ 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`.
運(yùn)行docker service ls
以查看正在運(yùn)行的服務(wù)的列表:
$ docker service ls ID NAME SCALE IMAGE COMMAND 9uk4639qpg7n helloworld 1/1 alpine ping docker.com
現(xiàn)在您已經(jīng)為群組部署了一項(xiàng)服務(wù),您已準(zhǔn)備好檢查該服務(wù)。