jesseduffield / lazydocker

The lazier way to manage everything docker
MIT License
35.29k stars 1.15k forks source link

Wrong Memory % in stats tab #560

Open konsalex opened 5 days ago

konsalex commented 5 days ago

Describe the bug A clear and concise description of what the bug is.

If I execute docker stats the memory percentage is fairly small ~5%, while lazydocker stats tab says its always around 100% of utilization.

To Reproduce Steps to reproduce the behavior:

Run a docker container, and go to stats tab and compare with actual docker stats.

I reproduced it with two versions of lazydocker and two OS (macos and ubuntu).

MacOS details ``` Version: 0.23.3 Date: BuildSource: homebrew Commit: OS: darwin Arch: amd64 ``` ``` Client: Version: 26.1.4 API version: 1.45 Go version: go1.21.11 Git commit: 5650f9b Built: Wed Jun 5 11:26:02 2024 OS/Arch: darwin/arm64 Context: desktop-linux Server: Docker Desktop 4.31.0 (153195) Engine: Version: 26.1.4 API version: 1.45 (minimum version 1.24) Go version: go1.21.11 Git commit: de5c9cf Built: Wed Jun 5 11:29:12 2024 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.6.33 GitCommit: d2d58213f83a351ca8f528a95fbd145f5654e957 runc: Version: 1.1.12 GitCommit: v1.1.12-0-g51d5e94 docker-init: Version: 0.19.0 GitCommit: de40ad0 ```
Ubuntu details ``` Version: 0.23.3 Date: 2024-05-26T04:20:34Z BuildSource: binaryRelease Commit: 152b36577137fd95f288e12cee5fd6d857a2d101 OS: linux Arch: amd64 ``` ``` ``` Client: Docker Engine - Community Version: 27.0.3 API version: 1.46 Go version: go1.21.11 Git commit: 7d4bcd8 Built: Sat Jun 29 00:02:23 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 27.0.3 API version: 1.46 (minimum version 1.24) Go version: go1.21.11 Git commit: 662f78c Built: Sat Jun 29 00:02:23 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.18 GitCommit: ae71819c4f5e67bb4d5ae76a6b735f29cc25774e runc: Version: 1.7.18 GitCommit: v1.1.13-0-g58aa920 docker-init: Version: 0.19.0 GitCommit: de40ad0 ``` ```

Expected behaviour

Show the correct percentage

Screenshots

CleanShot 2024-07-05 at 19 22 53@2x

Desktop (please complete the following information):

Additional context

None for now, if asked I can provide more info

konsalex commented 5 days ago

Could it be that the calculation does not align with how docker perform the calculation (removing the inactive_file): https://github.com/docker/cli/blob/master/cli/command/container/stats_helpers.go#L239

If this is a reference: https://github.com/jesseduffield/lazydocker/blob/master/pkg/commands/container_stats.go#L150