1. 程式人生 > >docker1.12 swarm 自定義映象的啟動

docker1.12 swarm 自定義映象的啟動

首先,這個問題是認識上的錯誤導致的,記錄在這裡希望後來人能少走彎路

#這樣啟動一個自定義的映象是沒有問題的,因為有td兩個引數

docker run -itd centos6/dubbo-cli /bin/bash

#而在swarm中就出現問題了,總是啟動不了

docker service create --replicas 2 --name local_7 kongxx/centos-7 /bin/bash

#日誌中確實有一個報錯,為此繞了一個大彎兒!搭建了私有倉庫,還弄了https。但還是不行

Jan 10 17:39:42 BETA-1-49 dockerd: time="2017-01-10T17:39:42.887662729+08:00" level=debug msg="Trying to pull kongxx/centos-7 from https://index.docker.io v1"
Jan 10 17:39:42 BETA-1-49 dockerd: time="2017-01-10T17:39:42.887699236+08:00" level=debug msg="hostDir: /etc/docker/certs.d/docker.io"
Jan 10 17:39:42 BETA-1-49 dockerd: time="2017-01-10T17:39:42.887910409+08:00" level=debug msg="[registry] Calling GET https://index.docker.io/v1/repositories/centos6/dubbo-cli/images"
Jan 10 17:39:42 BETA-1-49 dockerd: time="2017-01-10T17:39:42.888288873+08:00" level=debug msg="pull progress map[status:Pulling repository docker.io/centos6/dubbo-cli]"
Jan 10 17:39:43 BETA-1-49 dockerd: time="2017-01-10T17:39:43.924342733+08:00" level=error msg="Not continuing with pull after error: Error: image centos6/dubbo-cli:latest not found"
Jan 10 17:39:43 BETA-1-49 dockerd: time="2017-01-10T17:39:43.924412313+08:00" level=error msg="pulling image failed" error="Error: image kongxx/centos-7:latest not found" module=taskmanager task.id=8ebm1hq3n60pyvvbyulub2jyl

最後終於意識到了方向錯誤,將啟動命令改為:

docker service create --replicas 2 --name local_7 kongxx/centos-7 sleep 1000

服務終於順利啟動起來了。

原因就是沒有-td兩個引數時,執行完/bin/bash就會直接推出了,而docker swarm 會不斷的重啟。