如何指示计算引擎启动脚本在docker容器中执行

时间:2017-07-25 02:56:48

标签: docker google-compute-engine gcloud

我正在尝试在gcp计算引擎上运行启动脚本。该脚本启动,启动docker容器,并从该容器中运行命令。在启动脚本之外,整个过程没有错误,但显然启动脚本不是为此任务设计的吗?

我打电话。

gcloud compute instances create cloudml
    --image-family=container-vm
    --image-project=google-containers
    --boot-disk-size "40"
    --service-account "773889352370-compute@developer.gserviceaccount.com"
    --scopes "https://www.googleapis.com/auth/cloud-platform" 
    --metadata-from-file startup-script=Training.sh 

我可以通过串口监控启动脚本的日志。我可以看到它正确抓取脚本并开始。

第一个命令是docker run

sudo docker run -it --privileged -- gcr.io/api-project-773889352370/cloudmlengine 

从日志中,它会拉动和提取

Jul 24 21:54:02 cloudml startupscript: latest: Pulling from api-project-773889352370/cloudmlengine
Jul 24 21:54:02 cloudml startupscript: 9f0706ba7422: Pulling fs layer
Jul 24 21:54:02 cloudml startupscript: ec542cd45f0c: Pulling fs layer
Jul 24 21:54:02 cloudml startupscript: 07bcbd00d9b4: Pulling fs layer
Jul 24 21:54:02 cloudml startupscript: acc6d9961302: Pulling fs layer
Jul 24 21:54:02 cloudml startupscript: ef130a4b8961: Pulling fs layer
Jul 24 21:54:02 cloudml startupscript: 5ecac320219d: Pulling fs layer
Jul 24 21:54:02 cloudml startupscript: 54110f0dc661: Pulling fs layer

并最终

downloaded newer image for gcr.io/api-project-773889352370/cloudmlengine:latest

大。该命令应该启动一个容器。我希望从容器中运行脚本的其余部分。从ssh这没问题,docker run -it给我带来了一个交互式提示,但显然启动脚本不能同样工作。下一个命令是

git clone https://github.com/bw4sz/DeepMeerkat.git

但是整个事情有点没有明显的错误

Jul 24 21:59:53 [  422.646195] IPv6: ADDRCONF(NETDEV_UP): veth8286626: link is not ready
cloudml kernel: [  422.639552] device veth8286626 entered promiscuous mode
Jul 24 21:59:53 cloudml kernel: [  422.646195] IPv6: ADDRCONF(NETDEV_UP): veth8286626: link is not ready
[  422.938314] IPv6: ADDRCONF(NETDEV_CHANGE): veth8286626: link becomes ready
[  422.945723] docker0: port 1(veth8286626) entered forwarding state
[  422.951977] docker0: port 1(veth8286626) entered forwarding state
[  422.962994] IPv6: ADDRCONF(NETDEV_CHANGE): docker0: link becomes ready
Jul 24 21:59:53 cloudml kernel: [  422.938314] IPv6: ADDRCONF(NETDEV_CHANGE): veth8286626: link becomes ready
Jul 24 21:59:53 cloudml kernel: [  422.945723] docker0: port 1(veth8286626) entered forwarding state
Jul 24 21:59:53 cloudml kernel: [  422.951977] docker0: port 1(veth8286626) entered forwarding state
Jul 24 21:59:53 cloudml kernel: [  422.962994] IPv6: ADDRCONF(NETDEV_CHANGE): docker0: link becomes ready
[  437.956027] docker0: port 1(veth8286626) entered forwarding state
Jul 24 22:00:08 cloudml kernel: [  437.956027] docker0: port 1(veth8286626) entered forwarding state
Jul 24 22:00:29 cloudml sshd[3043]: Did not receive identification string from 139.162.75.112
Jul 24 22:02:26 cloudml sshd[3079]: Invalid user ftpuser from 128.199.72.218
Jul 24 22:02:26 cloudml sshd[3079]: input_userauth_request: invalid user ftpuser [preauth]
Jul 24 22:02:26 cloudml sshd[3079]: Connection closed by 128.199.72.218 [preauth]
Jul 24 22:06:07 cloudml sshd[3168]: Invalid user ftpuser1 from 128.199.72.218
Jul 24 22:06:07 cloudml sshd[3168]: input_userauth_request: invalid user ftpuser1 [preauth]
Jul 24 22:06:07 cloudml sshd[3168]: Connection closed by 128.199.72.218 [preauth]

它会持续一段时间。

我可以稍后ssh并尝试docker命令和下一个命令(git clone)并且它们运行没有问题,因此docker pull成功,没有错误。

Ben@cloudml:~$ sudo docker run -it --privileged -- gcr.io/api-project-773889352370/cloudmlengine
root@7d8ae18c2295:/#
root@7d8ae18c2295:/# git clone https://github.com/bw4sz/DeepMeerkat.git
Cloning into 'DeepMeerkat'...
remote: Counting objects: 768, done.
remote: Total 768 (delta 0), reused 0 (delta 0), pack-reused 768
Receiving objects: 100% (768/768), 41.38 MiB | 44.71 MiB/s, done.
Resolving deltas: 100% (517/517), done.
Checking connectivity... done.
root@7d8ae18c2295:/#

我是否会采取这种错误的方式?也许信息here这只是一次性工作,创建一个完整的kubernetes集群似乎是错误的。

0 个答案:

没有答案