1. 程式人生 > >096、運行第一個Service (Swarm03)

096、運行第一個Service (Swarm03)

image serve stat cat modify server manager container 進行

參考https://www.cnblogs.com/CloudMan6/p/7874609.html 上一節我們部署好了 Swarm 集群,下面部署一個運行httpd鏡像的service進行演示 [email protected]:~# docker service create --name web_server httpd # 創建一個httpd的service,名字是 web_server 9aa10i3l6xjwjacy95jsd061f overall progress: 1 out of 1 tasks 1/1: running [==================================================>] verify: Service converged service創建過程會占用一個終端,下面新開一個 host03 的終端,查看service創建過程中的一些狀態 [email protected]:~# docker service ls # 初始狀態,沒有任何service
ID NAME MODE REPLICAS IMAGE PORTS [email protected]:~# docker service ls # service創建中,要求副本數1 ,實際副本數0,如果耗時較長,多數是在下載鏡像 ID NAME MODE REPLICAS IMAGE PORTS 9aa10i3l6xjw web_server replicated 0/1 httpd:latest [email protected]:~# docker service ls # service創建成功,副本數達到 1
ID NAME MODE REPLICAS IMAGE PORTS 9aa10i3l6xjw web_server replicated 1/1 httpd:latest [email protected]:~# docker service ps web_server # 查看某service的運行狀態,目前該容器運行在host03上
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS jykct1jmfrte web_server.1 httpd:latest host03 Running Running 3 minutes ago [email protected]:~# docker ps # 在host03上驗證容器運行情況 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 128adb220d05 httpd:latest "httpd-foreground" 3 minutes ago Up 3 minutes 80/tcp web_server.1.jykct1jmfrtei1pu0jh5unwil [email protected]:~# docker service ls # docker service 命令只能在 swarm manager 上執行,在swarm worker 上執行會報如下錯誤 Error response from daemon: This node is not a swarm manager. Worker nodes can‘t be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager.

096、運行第一個Service (Swarm03)