How do I find out why my Docker service is in Pending state?

raarts picture raarts · Jan 13, 2017 · Viewed 12k times · Source

I'm playing Docker Swarm, and using a docker-compose.yml with docker deploy. All services get deployed except for one, which stays in Pending state. I have added a constraint that ties this service to one of the nodes. My question is not so much about this particular problem, but more about how to troubleshoot. The Docker documentation mentions possible causes for a service to be in pending state, but none of those apply (constraint problem, resource drainage).

Can I see the docker swarm 'thought process' somewhere? What is it thinking?

Edit: should have made it more clear that I am using the new, 1.12-introduced, swarm option.

Answer

minamijoyo picture minamijoyo · Jan 15, 2017

I will explain how to debug when the service does not start as expected in the docker swarm mode.

First of all, get a task ID with docker service ps <service-name>.

Next, it is useful to check meta data with docker inspect <task-id>. In particular, Error message before container start is in the status field, and then reconfirm whether it was started with the intended parameters.

If the task has container ID, it was abnormally exited after starting the container, so check the log of the container with docker logs <container-id>

I hope this would be some of help.