13

I am deploying a service(s) using swarm stack deploy. I am not able to deploy to other nodes, I wanna see what's wrong but have no way to see the logs of the services/tasks running on those nodes.

I tried

docker stack ps stackname

, which shows something under the "ERROR" column, such as "No such image", and "no suitable node", but I wanna see the full log of what is going on, otherwise seems impossible to solve any issues.

I also tried

docker service logs serviceid

but shows nothing.

Finally I also tried:

journalctl -fu docker.service

on the remote node, but it doesn't help too much, for example I cannot see the: "no suitable node" error there. Is there a way to see the logs/errors?

FraK
  • 919
  • 1
  • 13
  • 21
  • By default, journalctl doesn't show docker container logs. It needs to be set as the log driver. https://docs.docker.com/config/containers/logging/configure/. – Bernard Mar 10 '19 at 13:27

2 Answers2

24

You can use docker inspect on a task id to see any errors scheduling or starting the task. Use docker service ps on the service name, or docker stack ps on the stack name, to get the task id.

If the task gets scheduled, them an inspect in the container id will give details on why it stopped in the status section and container/service logs will show any output from your application. But if your task never starts, there won't be any container/service logs to view.

BMitch
  • 231,797
  • 42
  • 475
  • 450
  • 1
    Thanks, this was the answer but I did it the following way: "docker stack ls" (list all stacks, just to be sure the name of the stack) then "docker stack ps nameofstack" (to see all the tasks in the stack), from that I get the id of the stack and finally "docker inspect taskid". Maybe you could add this solution as well as this uses the "stack" command and it could be more understandable when using stack deploy. – FraK Mar 11 '19 at 08:20
  • Glad that helped, and good point on `docker stack ps`, I've included that option. – BMitch Mar 11 '19 at 10:27
9

docker stack ps --no-trunc <stackid>

Will show full error on container

Xeozim
  • 53
  • 5
user2440238
  • 91
  • 1
  • 1