Skip to content

Commit 29e82bb

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 595278d + 2969f9d commit 29e82bb

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

docker/client.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ func parseDockerHost(raw string) (dockerHost, error) {
7373
s = strings.TrimPrefix(s, "http://")
7474
s = strings.TrimPrefix(s, "https://")
7575
return dockerHost{"tcp", s}, nil
76+
case strings.HasPrefix(raw, "/"):
77+
// Absolute path without scheme - treat as unix socket
78+
return dockerHost{"unix", raw}, nil
7679
default:
77-
// default fallback to unix
80+
// For relative paths or other formats, also default to unix
7881
return dockerHost{"unix", raw}, nil
7982
}
8083
}
@@ -85,6 +88,13 @@ func CheckSocket(socketPath string) bool {
8588
if socketPath == "" {
8689
socketPath = "unix:///var/run/docker.sock"
8790
}
91+
92+
// Ensure the socket path is properly formatted
93+
if !strings.Contains(socketPath, "://") {
94+
// If no scheme provided, assume unix socket
95+
socketPath = "unix://" + socketPath
96+
}
97+
8898
host, err := parseDockerHost(socketPath)
8999
if err != nil {
90100
logger.Debug("Invalid Docker socket path '%s': %v", socketPath, err)
@@ -149,7 +159,13 @@ func IsWithinHostNetwork(socketPath string, targetAddress string, targetPort int
149159
func ListContainers(socketPath string, enforceNetworkValidation bool) ([]Container, error) {
150160
// Use the provided socket path or default to standard location
151161
if socketPath == "" {
152-
socketPath = "/var/run/docker.sock"
162+
socketPath = "unix:///var/run/docker.sock"
163+
}
164+
165+
// Ensure the socket path is properly formatted for the Docker client
166+
if !strings.Contains(socketPath, "://") {
167+
// If no scheme provided, assume unix socket
168+
socketPath = "unix://" + socketPath
153169
}
154170

155171
// Used to filter down containers returned to Pangolin

0 commit comments

Comments
 (0)