简体   繁体   中英

'docker service logs' overwriting and unstable after 'docker service update' in swarm mode

My docker services logs are usually working fine (printing in chronological order) but, after performing:

docker service update --force --image myimageregistry:mytag myservice 

if I request logs with:

docker service logs myservice

then I get some logs but many lines are missing and last lines don't correspond to the most recent actions. It seems as if older logs got written on top of newer ones and thus the final display is very messy.

Besides, if I keep an other terminal open following logs during the update, logs in that terminal are fine, but the issue is the same if I request them afterwards.

When you request service logs docker service logs $service docker goes and streams all the logs from all the containers that are still linked to the service via tasks, running or stopped. Docker doesn't try to cleanup these logs in any way so multiple tasks logs can all end up interleaved and in the wrong order.

If you specifically want the logs for just the current process you need to first enumerate the tasks associated with the service and then list the logs for one of the tasks:

$ docker service ps traefik_traefik
ID             NAME                                            IMAGE          NODE      DESIRED STATE   CURRENT STATE           ERROR                              PORTS
pwabbqdyucc3   traefik_traefik.n6fz7h5d122hads1rqwmmhgmw       traefik:v2.3   ...

$ docker service logs pwabb
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM