@@ -73,8 +73,11 @@ func parseDockerHost(raw string) (dockerHost, error) {
73
73
s = strings .TrimPrefix (s , "http://" )
74
74
s = strings .TrimPrefix (s , "https://" )
75
75
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
76
79
default :
77
- // default fallback to unix
80
+ // For relative paths or other formats, also default to unix
78
81
return dockerHost {"unix" , raw }, nil
79
82
}
80
83
}
@@ -85,6 +88,13 @@ func CheckSocket(socketPath string) bool {
85
88
if socketPath == "" {
86
89
socketPath = "unix:///var/run/docker.sock"
87
90
}
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
+
88
98
host , err := parseDockerHost (socketPath )
89
99
if err != nil {
90
100
logger .Debug ("Invalid Docker socket path '%s': %v" , socketPath , err )
@@ -149,7 +159,13 @@ func IsWithinHostNetwork(socketPath string, targetAddress string, targetPort int
149
159
func ListContainers (socketPath string , enforceNetworkValidation bool ) ([]Container , error ) {
150
160
// Use the provided socket path or default to standard location
151
161
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
153
169
}
154
170
155
171
// Used to filter down containers returned to Pangolin
0 commit comments