From 3858309a5de21ecf96add89f1e4d0018e81c8f1c Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Tue, 25 Nov 2025 12:40:27 +0100 Subject: [PATCH] Fix Docker container detection with sudo permissions Update systemd collector to use sudo for docker ps command to resolve permission issues when cm-agent user lacks docker group membership. This ensures Docker containers are properly discovered and displayed as sub-services under the docker service. Version: 0.1.160 --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/systemd.rs | 6 +++--- dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b542ea3..a5b7e28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.159" +version = "0.1.160" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.159" +version = "0.1.160" dependencies = [ "anyhow", "async-trait", @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.159" +version = "0.1.160" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index dfaa9bb..e0b23ec 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.159" +version = "0.1.160" edition = "2021" [dependencies] diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index 85d52ce..0636f04 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -756,9 +756,9 @@ impl SystemdCollector { fn get_docker_containers(&self) -> Vec<(String, String)> { let mut containers = Vec::new(); - // Check if docker is available - let output = Command::new("docker") - .args(&["ps", "--format", "{{.Names}},{{.Status}}"]) + // Check if docker is available (use sudo for permissions) + let output = Command::new("sudo") + .args(&["docker", "ps", "--format", "{{.Names}},{{.Status}}"]) .output(); let output = match output { diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index cef9dbe..dd3e9c5 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.159" +version = "0.1.160" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 1873cab..f4f425d 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.159" +version = "0.1.160" edition = "2021" [dependencies]