13

I'm playing around now with docker 1.12, created a service and noticed there is a stage of "preparing" when I ran "docker service tasks xxx".

I can only guess that on this stage the images are being pulled or updated.

My question is: how can I see the logs for this stage? Or more generally: how can I see the logs for docker service tasks?

Shay Tsadok
  • 913
  • 1
  • 7
  • 26

2 Answers2

11

I have been using docker-machine for emulating different "hosts" in my development environment.

This is what I did to figure out what was going on during this "Preparing" phase for my services:

docker service ps <serviceName>

You should see the nodes (machines) where your service was scheduled to run. Here you'll see the "Preparing" message.

Use docker-machine ssh to connect to a particular machine:

docker-machine ssh <nameOfNode/Machine>

Your prompt will change. You are now inside another machine. Inside this other machine do this:

tail -f /var/log/docker.log

You'll see the "daemon" log for that machine. There you'll see if that particular daemon is doing the "pull" or what's is doing as part of the service preparation. In my case, I found something like this:

time="2016-09-05T19:04:07.881790998Z" level=debug msg="pull progress map[progress:[===========================================> ] 112.4 MB/130.2 MB status:Downloading

Which made me realise that it was just downloading some images from my docker account.

cSn
  • 2,796
  • 3
  • 23
  • 29
0

Your assumption (about pulling during preparation) is correct.

There is no log command yet for tasks, but you could certainly connect to that daemon and do docker logs in the regular way.

johnharris85
  • 17,264
  • 5
  • 48
  • 52
  • The problem is that docker logs is good only after I have a container. I'm looking for something pre-container phase... – Shay Tsadok Jul 18 '16 at 20:51
  • Ah so you're interesting in the daemon logs themselves? I.e. what is happening with the API calls during creation? – johnharris85 Jul 18 '16 at 21:10
  • Yes, but to be focused on the task themselves (the daemon is doing a lot of other stuff I'm not interesting with) – Shay Tsadok Jul 18 '16 at 21:24
  • Right. There is nothing that does what you want. There is nothing that currently does this for a regular run either right? What logs / information would you want to see? – johnharris85 Jul 18 '16 at 21:49
  • I just want to see what's behind the scene. For instance: now I found another state which is "New" and I had a situation in which the task is not getting out of this stage. The daemon logs are too general and I could not find the problem there. Only after elimination I found out it was related to the exposed ports of the service. – Shay Tsadok Jul 18 '16 at 23:06