diff --git a/internal/dockeragent/agent.go b/internal/dockeragent/agent.go index acaf56ad0..416d27d36 100644 --- a/internal/dockeragent/agent.go +++ b/internal/dockeragent/agent.go @@ -441,6 +441,18 @@ func buildRuntimeCandidates(preference RuntimeKind) []runtimeCandidate { label: "podman rootless socket", }) + // Discover rootless Podman sockets for other users (e.g. agent runs as root + // but Podman rootless is installed for uid 1000) + if matches, err := filepath.Glob("/run/user/*/podman/podman.sock"); err == nil { + for _, match := range matches { + sockURI := "unix://" + match + add(runtimeCandidate{ + host: sockURI, + label: fmt.Sprintf("podman rootless socket (%s)", match), + }) + } + } + add(runtimeCandidate{ host: "unix:///run/podman/podman.sock", label: "podman system socket", @@ -489,6 +501,17 @@ func buildRuntimeCandidates(preference RuntimeKind) []runtimeCandidate { label: "podman rootless socket", }) + // Discover rootless Podman sockets for other users + if matches, err := filepath.Glob("/run/user/*/podman/podman.sock"); err == nil { + for _, match := range matches { + sockURI := "unix://" + match + add(runtimeCandidate{ + host: sockURI, + label: fmt.Sprintf("podman rootless socket (%s)", match), + }) + } + } + add(runtimeCandidate{ host: "unix:///run/podman/podman.sock", label: "podman system socket", @@ -509,6 +532,18 @@ func buildRuntimeCandidates(preference RuntimeKind) []runtimeCandidate { label: "docker rootless socket", }) + // Discover rootless Docker sockets for other users (e.g. agent runs as root + // but Docker rootless is installed for uid 1000) + if matches, err := filepath.Glob("/run/user/*/docker.sock"); err == nil { + for _, match := range matches { + sockURI := "unix://" + match + add(runtimeCandidate{ + host: sockURI, + label: fmt.Sprintf("docker rootless socket (%s)", match), + }) + } + } + // macOS Docker Desktop socket if home := os.Getenv("HOME"); home != "" { add(runtimeCandidate{