Skip to content

Commit ea3f9f3

Browse files
committed
fix(server-health): detect custom default-address-pools via docker info
/etc/docker/daemon.json isn't mounted into the dokploy container, only docker.sock is, so cat-ing it always failed silently. Read the effective config over the already-mounted socket instead. Fixes Dokploy#5383
1 parent 1e6ab0f commit ea3f9f3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎packages/server/src/services/server-health.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ diskTotal=$(df -B1 / 2>/dev/null | awk 'NR==2{print $2}'); [ -z "$diskTotal" ] &
118118
diskUsed=$(df -B1 / 2>/dev/null | awk 'NR==2{print $3}'); [ -z "$diskUsed" ] && diskUsed=0
119119
120120
networkCount=$(docker network ls -q 2>/dev/null | wc -l | tr -d ' ')
121-
daemonConfigB64=$(cat /etc/docker/daemon.json 2>/dev/null | base64 2>/dev/null | tr -d '\\n')
121+
# /etc/docker/daemon.json isn't mounted into the dokploy container (only docker.sock is), so read
122+
# the effective config over the socket instead of the file.
123+
daemonConfigB64=$(docker info --format '{{json .DefaultAddressPools}}' 2>/dev/null | base64 2>/dev/null | tr -d '\\n')
122124
123125
daemonLogsToEpoch=$(date +%s 2>/dev/null); [ -z "$daemonLogsToEpoch" ] && daemonLogsToEpoch=0
124126
daemonLogsFromEpoch=$((daemonLogsToEpoch - ${sinceHours} * 3600))
@@ -319,11 +321,11 @@ export const getServerHealth = async (
319321
.filter(Boolean);
320322

321323
let addressPools: unknown = null;
322-
const daemonConfigText = b64Decode(parsed.daemonConfigBase64);
324+
const daemonConfigText = b64Decode(parsed.daemonConfigBase64).trim();
323325
if (daemonConfigText) {
324326
try {
325-
addressPools =
326-
JSON.parse(daemonConfigText)?.["default-address-pools"] ?? null;
327+
// `docker info` already returns the pools array (or `null`) directly, unlike daemon.json.
328+
addressPools = JSON.parse(daemonConfigText) ?? null;
327329
} catch {
328330
addressPools = null;
329331
}

0 commit comments

Comments
 (0)