This repository was archived by the owner on Nov 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,21 +21,25 @@ package metrics
2121
2222import (
2323 "net"
24+ "os"
2425 "path/filepath"
2526
2627 "github.com/docker/docker/pkg/homedir"
2728)
2829
2930var (
30- socket = ""
31+ socket = "/var/run/docker-cli.sock "
3132)
3233
3334func init () {
3435 // Attempt to retrieve the Docker CLI socket for the current user.
3536 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
3943}
4044
4145func conn () (net.Conn , error ) {
You can’t perform that action at this time.
0 commit comments