Skip to content

Commit 5585c60

Browse files
authored
Update podman socket path for mac (#2164)
This is to make podman work on macOS without requiring podman desktop. Fix #2160
1 parent d421ce6 commit 5585c60

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pkg/container/docker/sdk/client_unix.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,25 @@ func findPodmanSocket() (string, error) {
132132
logger.Debugf("Failed to check Podman socket at %s: %v", userSocketPath, err)
133133
}
134134

135+
// Check TMPDIR for Podman Machine API sockets (macOS)
136+
// The socket path follows the pattern: $TMPDIR/podman/<machine-name>-api.sock
137+
if tmpDir := os.Getenv("TMPDIR"); tmpDir != "" {
138+
podmanTmpDir := filepath.Join(tmpDir, "podman")
139+
if _, err := os.Stat(podmanTmpDir); err == nil {
140+
// Look for any -api.sock files (there may be multiple machines)
141+
matches, err := filepath.Glob(filepath.Join(podmanTmpDir, "*-api.sock"))
142+
if err == nil && len(matches) > 0 {
143+
// Use the first available API socket
144+
socketPath := matches[0]
145+
logger.Debugf("Found Podman machine API socket at %s", socketPath)
146+
return socketPath, nil
147+
}
148+
logger.Debugf("No Podman machine API sockets found in %s", podmanTmpDir)
149+
} else {
150+
logger.Debugf("Podman temp directory not found at %s: %v", podmanTmpDir, err)
151+
}
152+
}
153+
135154
return "", fmt.Errorf("podman socket not found in standard locations")
136155
}
137156

0 commit comments

Comments
 (0)