fix(docker-widget): memory usage wrong (#4266)

This commit is contained in:
Meier Lukas
2025-10-13 23:52:40 +02:00
committed by GitHub
parent afca8007f1
commit cccec5e195

View File

@@ -47,7 +47,7 @@ async function getContainersWithStatsAsync() {
const instance = dockerInstances.find(({ host }) => host === container.instance)?.instance;
if (!instance) return null;
const stats = await instance.getContainer(container.Id).stats({ stream: false });
const stats = await instance.getContainer(container.Id).stats({ stream: false, "one-shot": true });
return {
id: container.Id,
@@ -60,7 +60,8 @@ async function getContainersWithStatsAsync() {
return icon.name.toLowerCase().includes(extractedImage.toLowerCase());
})?.url ?? null,
cpuUsage: calculateCpuUsage(stats),
memoryUsage: stats.memory_stats.usage,
// memory usage by default includes cache, which should not be shown as it is also not shown with docker stats command
memoryUsage: stats.memory_stats.usage - stats.memory_stats.stats.cache,
image: container.Image,
ports: container.Ports,
};