File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -21,21 +21,25 @@ package metrics
21
21
22
22
import (
23
23
"net"
24
+ "os"
24
25
"path/filepath"
25
26
26
27
"github.com/docker/docker/pkg/homedir"
27
28
)
28
29
29
30
var (
30
- socket = ""
31
+ socket = "/var/run/docker-cli.sock "
31
32
)
32
33
33
34
func init () {
34
35
// Attempt to retrieve the Docker CLI socket for the current user.
35
36
if home := homedir .Get (); home != "" {
36
- socket = filepath .Join (home , ".docker/desktop/docker-cli.sock" )
37
- } // else: On Linux we don't expect to have a global CLI socket, so leave it empty and let connections fail.
38
- overrideSocket () // nop, unless built for e2e testing
37
+ tmp := filepath .Join (home , ".docker/desktop/docker-cli.sock" )
38
+ if _ , err := os .Stat (tmp ); err == nil {
39
+ socket = tmp
40
+ } // else: fall back to the global CLI socket path (used by DD in WSL)
41
+ } // else: fall back to the global CLI socket path (used by DD in WSL)
42
+ overrideSocket () // no-op, unless built for e2e testing
39
43
}
40
44
41
45
func conn () (net.Conn , error ) {
You can’t perform that action at this time.
0 commit comments