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 会不断的重启。

你可能感兴趣的:(docker1.12 swarm 自定义镜像的启动)