docker swarm how to find out why service can't start

Viewed 44105

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

  • Can't download image from registry
  • Constraints that can't be fulfilled

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?

2 Answers

Another trick I've been using is from this article. I was quite stuck and this trick got me a bit further down the road:

docker run --network my-network -it --rm --entrypoint bash my-service

The problem is that when I ran it this way, I could start the service and interact with the other services in the swarm (via the external overlay network). But when I tried to start all three services with Docker Compose, the above service failed to start. So I'm still stuck, but slightly closer than before.

I often grep the syslog too, which sometimes reveals some nuggets:

less /var/log/syslog | grep docker
less /var/log/syslog | grep error

And, finally, here is a trick I found that sometimes works:

https://faun.pub/debug-docker-swarm-services-eec20fe3d13e

Related