docker logs --timestamps
does not correctly handle long logs (>16kiB) that were split when stored
#4941
Labels
docker logs --timestamps
does not correctly handle long logs (>16kiB) that were split when stored
#4941
Description
Long logs get split into 16 kiB segments by the log driver (at least the json lines one).
When requesting
--timestamps
, we would expect to see a timestamp at the start of the log line, but the timestamp is also injected into the middle of the output for every 16k characters.This was inspired from grafana/loki#12197, as I thought "surely the docker cli does this without mangling the logs" but sadly it seems not :( I guess that, when requesting timestamps, it is not enough to directly forward the byte streams - the timestamps should be stripped from frames that have not immediately followed a newline.
Reproduce
container=$(docker create python:latest python3 -c 'print("-" * 16400)')
docker start $container
docker logs --timestamps $container
Expected behavior
The CLI should show timestamps at the start of the line, but not in the middle of the lines.
docker version
Client: Docker Engine - Community Version: 24.0.7 API version: 1.43 Go version: go1.20.10 Git commit: afdd53b Built: Thu Oct 26 09:07:41 2023 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 24.0.7 API version: 1.43 (minimum version 1.12) Go version: go1.20.10 Git commit: 311b9ff Built: Thu Oct 26 09:07:41 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.25 GitCommit: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f runc: Version: 1.1.10 GitCommit: v1.1.10-0-g18a0cb0 docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info
Additional Info
No response
The text was updated successfully, but these errors were encountered: