cli
cli copied to clipboard
`docker logs --timestamps` does not correctly handle long logs (>16kiB) that were split when stored
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 - Observe the presence of two timestamps, with the second one having been injected after 16384 characters.
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
Client: Docker Engine - Community
Version: 24.0.7
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.11.2
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.21.0
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 6
Running: 4
Paused: 0
Stopped: 2
Images: 42
Server Version: 24.0.7
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
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: active
NodeID: woua6888bdr2pa6qs2jwl7nnu
Is Manager: true
ClusterID: t5vjx0ip74vvgf58v3xg0pbks
Managers: 1
Nodes: 1
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 172.19.158.143
Manager Addresses:
172.19.158.143:2377
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
runc version: v1.1.10-0-g18a0cb0
init version: de40ad0
Security Options:
seccomp
Profile: builtin
Kernel Version: 5.15.146.1-microsoft-standard-WSL2
Operating System: Ubuntu 23.10
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 15.62GiB
Name: LPCP2158
ID: 7CGJ:WOZO:CHP4:FBWC:PIJ4:JX4C:DQU7:I27X:IHY2:HCZQ:2CH3:BHIB
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
Additional Info
No response