Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2177 from p1-0tr/ps-global-cli-sock-fallback
Browse files Browse the repository at this point in the history
Fall back to global CLI socket on Linux
  • Loading branch information
glours authored Jul 25, 2022
2 parents 2d878f7 + cfa212f commit 77e61c2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cli/metrics/conn_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,25 @@ package metrics

import (
"net"
"os"
"path/filepath"

"github.com/docker/docker/pkg/homedir"
)

var (
socket = ""
socket = "/var/run/docker-cli.sock"
)

func init() {
// Attempt to retrieve the Docker CLI socket for the current user.
if home := homedir.Get(); home != "" {
socket = filepath.Join(home, ".docker/desktop/docker-cli.sock")
} // else: On Linux we don't expect to have a global CLI socket, so leave it empty and let connections fail.
overrideSocket() // nop, unless built for e2e testing
tmp := filepath.Join(home, ".docker/desktop/docker-cli.sock")
if _, err := os.Stat(tmp); err == nil {
socket = tmp
} // else: fall back to the global CLI socket path (used by DD in WSL)
} // else: fall back to the global CLI socket path (used by DD in WSL)
overrideSocket() // no-op, unless built for e2e testing
}

func conn() (net.Conn, error) {
Expand Down

0 comments on commit 77e61c2

Please sign in to comment.