我正在使用调用 docker 映像的 cloudinit 文件启动 GCE 服务器。启动时,拉取 docker 映像失败,但如果我在登录时运行相同的服务,它会成功。我希望它在启动时工作。
查看服务日志,似乎它错误地为 docker pull 加上前缀docker.io
,因此作业失败。
我可以做些什么来防止这种情况发生吗?在尝试 docker pull 之前,我是否可能需要等待或检查要加载的其他内容?
这是我的云初始化文件:
#cloud-config
users:
- name: shinyuser
uid: 2000
write_files:
- path: /etc/systemd/system/shinyserver.service
permissions: 0644
owner: root
content: |
[Unit]
Description=Shiny server
[Service]
ExecStart=/usr/bin/docker run --name=vdshinyserver -p 80:3838 -v /home/shinyuser/shinyapps/:/srv/shiny-server/ -v /home/shinyuser/srv/shinylog/:/var/log/ rocker/shiny
ExecStop=/usr/bin/docker stop vdshinyserver
runcmd:
- systemctl daemon-reload
- systemctl start shinyserver.service
这是日志:
mark@xxxshiny ~ $ sudo journalctl -u shinyserver
-- Logs begin at Wed 2016-10-05 08:39:06 UTC, end at Wed 2016-10-05 08:39:46 UTC. --
Oct 05 08:39:11 xxxshiny docker[1016]: Unable to find image 'rocker/shiny:latest' locally
Oct 05 08:39:26 xxxshiny docker[1016]: Pulling repository docker.io/rocker/shiny
Oct 05 08:39:31 xxxshiny docker[1016]: /usr/bin/docker: Tag latest not found in repository docker.io/rocker/shiny.
Oct 05 08:39:31 xxxshiny docker[1016]: See '/usr/bin/docker run --help'.
Oct 05 08:39:31 xxxshiny docker[1045]: Error response from daemon: No such container: vdshinyserver
mark@visit-dubai-shiny ~ $ sudo systemctl start shinyserver.service
mark@visit-dubai-shiny ~ $ sudo journalctl -u shinyserver
...
Oct 05 08:42:22 xxxshiny docker[1117]: Unable to find image 'rocker/shiny:latest' locally
Oct 05 08:42:23 xxxshiny docker[1117]: latest: Pulling from rocker/shiny
Oct 05 08:42:23 xxxshiny docker[1117]: a84f66826a7f: Pulling fs layer
Oct 05 08:42:23 xxxshiny docker[1117]: aaf7c0da390d: Pulling fs layer
...etc...