docker service create --name webserver -p 8880:80 httpd
docker service ls您應該看到以下輸出:
sudo docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
dk7qnjx65dnx webserver replicated 1/1 httpd:latest *:8880->80/tcp
接下來,使用以下命令在兩個容器之間擴展Web服務器服務: docker service scale webserver=2
ebserver scaled to 2
overall progress: 1 out of 2 tasks
1/2: preparing
2/2: running
overall progress: 2 out of 2 tasks
1/2: running
2/2: running
verify: Service converged
然後,使用以下命令檢查Web服務器服務的狀態:docker service ps webserver您應該看到以下輸出:
sudo docker service ps webserver
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
wdpxz2bh9vu7 webserver.1 httpd:latest pi-GB-BSi5A-6200 Running Running 3 minutes ago
olv9p594q03w webserver.2 httpd:latest ubuntu-mate Running Running 58 seconds ago