warn when a host's kernel has cgroup memory accounting disabled

This commit is contained in:
Jarek Krochmalski committed 2026-09-12 16:24:13 +02:00
1 parent 5954e22297
commit 5512357a74
6 files changed
+121 -6

No files matched your search

+5 -1
View File
@@ -12505,6 +12505,9 @@
},
"name": {
"type": "string"
},
"memoryLimitSupported": {
"type": "boolean"
}
}
},
@@ -12523,7 +12526,8 @@
"serverVersion": "string",
"containers": 0,
"images": 0,
"name": "string"
"name": "string",
"memoryLimitSupported": true
},
"hawser": {}
}
+30
View File
@@ -0,0 +1,30 @@
/**
* Whether the daemon's kernel supports per-container memory accounting, read from
* Docker `/info`. When the cgroup memory controller is disabled in the kernel boot
* config (common on Raspberry Pi and some ARM boards), the daemon reports
* `MemoryLimit: false` and every container's memory usage shows as 0. Docker itself
* detects this - we surface it so the user isn't left guessing why memory is blank.
*/
export interface MemorySupportInfo {
/** true = the UI can show a warning that memory accounting is off. */
warn: boolean;
/** Docker's own `/info.MemoryLimit`. */
memoryLimitSupported: boolean;
/** Docker's own `/info.SwapLimit`. */
swapLimitSupported: boolean;
}
/**
* Derive the memory-support flags from a Docker `/info` response. `MemoryLimit`/
* `SwapLimit` are booleans; a missing/undefined field is treated as SUPPORTED (no
* warning) so an older daemon or a partial info payload never produces a false alarm.
*/
export function memorySupportFromInfo(info: { MemoryLimit?: boolean; SwapLimit?: boolean } | null | undefined): MemorySupportInfo {
const memoryLimitSupported = info?.MemoryLimit !== false;
const swapLimitSupported = info?.SwapLimit !== false;
return { warn: !memoryLimitSupported, memoryLimitSupported, swapLimitSupported };
}
/** Link to the manual section explaining how to enable cgroup memory accounting. */
export const MEMORY_SUPPORT_DOC_URL = 'https://dockhand.pro/manual/#troubleshooting-rpi-memory';