Open pveierland opened 6 months ago
Thanks for reporting
I'm not sure if this is possible to fix, or at least this would require careful consideration; when running swarm services, those services are distributed in the cluster, and may be running on different nodes. In addition, the logs printed can originate from STDOUT and STDERR, one of which is buffered, the other is not; for the latter one there's a (still open) ticket; https://github.com/moby/moby/issues/31706
The docker service logs
will print such logs when they arrive which, in a distributed system, may mean that log entries from different nodes may arrive at different moment. So to sort these log entries, all log-entries would have to be buffered before they can be sorted, which would only be possible in the "one-off" (without --follow
) case, and in that case would still have a potential of requiring a large amount of memory to be used (buffering all log entries). For the --folow
case, things will be more complicated, as there's no real way to predict when new log-entries arrive (if any) from all instances of a service.
For debugging purposes, you could consider using sort
to sort the output to see if that addresses your immediate issue;
docker service logs --timestamps myservice 2>&1 | sort
For collecting logs of your swarm cluster, using a log-aggregator can also be a good option; in that case logs from the cluster can be collected centrally (https://docs.docker.com/config/containers/logging/configure/)
Description
docker service logs <service>
does not return results in chronological order.Reproduce
docker service logs --timestamps <service>
.Example output:
Expected behavior
The expected results from the command is to see log results in chronological order as determined by their timestamps.
docker version
docker info
Additional Info
No response