fix(sentinel): start sentinel on servers with a userns-remap daemon

Closes #12168

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-10-15 22:31:04 +02:00
co-authored by Claude Opus 5.5
parent 7466da12a2
commit 783a103d97
2 changed files with 9 additions and 1 deletions
+3 -1
View File
@@ -148,7 +148,9 @@ class StartSentinel
? '-v '.escapeshellarg("{$trafficLogDirectory}:{$trafficLogDirectory}:ro").' '
: '';
$network = $server->isLocalhost() ? ' --network coolify' : '';
$dockerCommand = "docker run -d$network $dockerEnvironments --name coolify-sentinel --restart unless-stopped -v /var/run/docker.sock:/var/run/docker.sock -v $mountDir:/app/db {$trafficMount}--pid host --health-cmd \"curl --fail http://127.0.0.1:8888/api/health || exit 1\" --health-start-period 120s --health-interval 10s --health-retries 3 --add-host=host.docker.internal:host-gateway --label $dockerLabels $image";
// A userns-remap daemon refuses --pid host unless the container opts out of remapping.
// On other daemons --userns host has no effect. https://docs.docker.com/engine/security/userns-remap/
$dockerCommand = "docker run -d$network $dockerEnvironments --name coolify-sentinel --restart unless-stopped -v /var/run/docker.sock:/var/run/docker.sock -v $mountDir:/app/db {$trafficMount}--userns host --pid host --health-cmd \"curl --fail http://127.0.0.1:8888/api/health || exit 1\" --health-start-period 120s --health-interval 10s --health-retries 3 --add-host=host.docker.internal:host-gateway --label $dockerLabels $image";
$server->sentinelHeartbeat(isReset: true);
$server->forceFill(['sentinel_waiting_since' => now()])->save();
@@ -180,6 +180,12 @@ it('starts sentinel with a restart policy so Docker restarts it after a crash or
expect($script)->toContain('--name coolify-sentinel --restart unless-stopped ');
});
it('starts sentinel in the host user namespace so --pid host works on a userns-remap daemon', function () {
$script = runStartSentinelAndCaptureScript(sentinelTrafficServer($this, 'TRAEFIK', analyticsEnabled: false));
expect($script)->toContain('--userns host --pid host ');
});
it('does not touch the access log when traffic analytics cannot run', function (?string $proxyType, bool $analyticsEnabled) {
$server = sentinelTrafficServer($this, $proxyType, $analyticsEnabled);