码头工人蜂拥而至,找出服务为何无法启动 [英] docker swarm how to find out why service can't start

查看:102
本文介绍了码头工人蜂拥而至,找出服务为何无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常遇到问题,因为我在具有多个节点的docker swarm上部署的服务无法启动,并且没有生成可通过 docker service logs {serviceName}

I often have problems because a service that I deploy on docker swarm with multiple nodes won't start and there are not logs generated that I can look at with docker service logs {serviceName}

有很多服务无法启动的原因,例如

There are many possible reasons for a service not to start such as


  • 无法从注册表中下载图像

  • 无法实现的约束

我很难找出为什么容器无法启动。我找到了命令 docker service ps {serviceName} ,该命令列出了一个或多个服务的任务以及一条简短的错误消息(如果有错误)。但是,当我尝试使用 docker服务日志{taskId} (应该显示任务日志)检查任务时,我从守护程序得到错误响应:找不到任务3lkgo8t2sn7k

I have trouble finding out why a container won't start. I found the command docker service ps {serviceName} which List the tasks of one or more services and a short error message (if there was an error). However when I try to inspect the task with docker service logs {taskId} (which should show logs of a task) I get Error response from daemon: task 3lkgo8t2sn7k not found.

有人可以帮助我获得一条完整的错误消息,为什么服务无法启动?

Can anyone help me get a full error message why a service won't start?

推荐答案

我找到了一个方便的解决方案。

I found one handy solution to the problem.

docker service ps --no-trunc {serviceName}

将会显示下载图像时出现错误,

which will show errors with downloading images, mounting nfs volumes amongst others.

----------------------更新

---------------------- UPDATE

并非所有错误都可以通过上述方式找到。另一个有用的工具是查看docker deamon日志,该日志可以按照 stackoverflow

Not all errors can be found in the way described above. Another usefull tool is looking at the docker deamon logs which can be done the follwing way as explained on stackoverflow:

journalctl -u docker.service | tail -n 50 




这取决于您的操作系统。以下是一些位置,带有一些操作系统的命令:

It depends on your OS. Here are the few locations, with commands for few Operating Systems:


  • Ubuntu(使用upstart的旧版本)- / var /log/upstart/docker.log

  • Ubuntu(使用systemd新增)- journalctl -u docker.service

  • Boot2Docker- /var/log/docker.log

  • Debian GNU / Linux- /var/log/daemon.log

  • CentOS- /var/log/daemon.log | grep docker

  • CoreOS- journalctl -u docker.service

  • Fedora- journalctl -u docker.service

  • Red Hat Enterprise Linux服务器- / var / log /消息| grep docker

  • OpenSuSE- journalctl -u docker.service

  • OSX-〜/ Library / Containers / com.docker.docker / Data / com.docker.driver.amd64-linux / log / d‌ocker.log

  • Windows- Get-EventLog -LogName应用程序-Source Docker -After(Get-Date).AddMinutes(-5)|排序对象时间,如前所述
    此处

  • Ubuntu (old using upstart ) - /var/log/upstart/docker.log
  • Ubuntu (new using systemd ) - journalctl -u docker.service
  • Boot2Docker - /var/log/docker.log
  • Debian GNU/Linux - /var/log/daemon.log
  • CentOS - /var/log/daemon.log | grep docker
  • CoreOS - journalctl -u docker.service
  • Fedora - journalctl -u docker.service
  • Red Hat Enterprise Linux Server - /var/log/messages | grep docker
  • OpenSuSE - journalctl -u docker.service
  • OSX - ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/log/d‌​ocker.log
  • Windows - Get-EventLog -LogName Application -Source Docker -After (Get-Date).AddMinutes(-5) | Sort-Object Time, as mentioned here.

这篇关于码头工人蜂拥而至,找出服务为何无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆