docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.7k stars 5.19k forks source link

Compose logs of specified services (2+) are not timestamp sequential #10377

Open JCMarques15 opened 1 year ago

JCMarques15 commented 1 year ago

Description

When specifying 2 or more services with the command:

The output comes out of sequence. it always prints all the log lines of one container and then the second, instead of the expected interlaced way based on timestamp of the log line as it is when you dont specify any service and rather grab all the services.

I am not sure if this is a bug or intended but though of making you guys aware in case it is a bug. Thank for your time and my apologies if this was intended.

Steps To Reproduce

docker-compose logs <service 1/n> <service 2/n> ...

Compose Version

docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  scan: Docker Scan (Docker Inc., v0.21.0)

Server:
 Containers: 36
  Running: 16
  Paused: 0
  Stopped: 20
 Images: 104
 Server Version: 20.10.21
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.4.0-131-generic
 Operating System: Ubuntu 20.04.5 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 7.77GiB
 Name: ****
 ID: ****
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support

Anything else?

No response

ndeloof commented 1 year ago

timestamps are added by Docker engine, we just receive a raw string, which includes timestamp as a prefix. being able to re-order logs in time would require to parse logs for timestamp and implement time-sorting.

JCMarques15 commented 1 year ago

Ha i see, thank you for taking the time to explain it. It would be cool to see that implemented, but I'm sure there are many more important things to implement before this.

Thank you once again for the time, have a great day!

JCMarques15 commented 1 year ago

Ha i see, thank you for taking the time to explain it. It would be cool to see that implemented, but I'm sure there are many more important things to implement before this.

Thank you once again for the time, have a great day!