从 cloud-init 启动 运行 docker 错误地将 "docker.io" 前缀添加到图像名称
Launching run docker from cloud-init incorrectly prefixes "docker.io" to image name
我正在使用调用 docker 图像的 cloudinit 文件启动 GCE 服务器。启动时,拉取 docker 图像失败,但如果我 运行 相同的服务在登录时成功。我希望它能在启动时运行。
查看服务日志,它似乎错误地在 docker 拉取前缀前加上 docker.io
,因此作业失败。
我可以做些什么来防止这种情况发生?在尝试 docker pull 之前,我是否可能需要等待或检查其他内容以加载?
这是我的 cloud-init 文件:
#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...
我编辑了我的 cloudinit 以匹配 Docker documentation 以在文件中包含 docker.service
的要求,现在它可以工作了:
#cloud-config
users:
- name: shinyuser
uid: 2000
write_files:
- path: /etc/systemd/system/shinyserver.service
permissions: 0644
owner: root
content: |
[Unit]
Description=VisitDubai Shiny server for reporting
Requires=docker.service
After=docker.service
[Service]
Restart=always
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
我正在使用调用 docker 图像的 cloudinit 文件启动 GCE 服务器。启动时,拉取 docker 图像失败,但如果我 运行 相同的服务在登录时成功。我希望它能在启动时运行。
查看服务日志,它似乎错误地在 docker 拉取前缀前加上 docker.io
,因此作业失败。
我可以做些什么来防止这种情况发生?在尝试 docker pull 之前,我是否可能需要等待或检查其他内容以加载?
这是我的 cloud-init 文件:
#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...
我编辑了我的 cloudinit 以匹配 Docker documentation 以在文件中包含 docker.service
的要求,现在它可以工作了:
#cloud-config
users:
- name: shinyuser
uid: 2000
write_files:
- path: /etc/systemd/system/shinyserver.service
permissions: 0644
owner: root
content: |
[Unit]
Description=VisitDubai Shiny server for reporting
Requires=docker.service
After=docker.service
[Service]
Restart=always
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