Skip to content

Commit

Permalink
docker: update docker-desktop socket check (#6395)
Browse files Browse the repository at this point in the history
fixes #6394

Signed-off-by: Nick Santos <nick.santos@docker.com>
  • Loading branch information
nicks authored Jun 12, 2024
1 parent 90b6ad3 commit 0edf8bd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions internal/docker/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ func isDefaultHost(e Env) bool {
// Docker Desktop for Mac 4.13+ - socket is in ~/.docker/run/docker.sock
(strings.HasPrefix(host, "unix://") && strings.HasSuffix(host, "/.docker/run/docker.sock")) ||

// Docker Desktop for Windows 4.31+
strings.HasPrefix(host, "npipe:////./pipe/dockerDesktop") ||

// Rancher Desktop without admin access on Linux/Mac is in ~/.rd/docker.sock
(strings.HasPrefix(host, "unix://") && strings.HasSuffix(host, "/.rd/docker.sock"))

Expand Down
26 changes: 25 additions & 1 deletion internal/docker/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,33 @@ func (f *fakeDaemonClient) DaemonHost() string {
return f.host
}

func TestColimaEnv(t *testing.T) {
func TestEnv(t *testing.T) {

table := []EnvTest{
{
product: clusterid.ProductDockerDesktop,
kubecontext: "docker-desktop",
dockerHost: "npipe:////./pipe/dockerDesktopLinuxEngine",
match: true,
},
{
product: clusterid.ProductDockerDesktop,
kubecontext: "docker-desktop",
dockerHost: "npipe:////./pipe/docker_engine",
match: true,
},
{
product: clusterid.ProductDockerDesktop,
kubecontext: "docker-desktop",
dockerHost: "unix:///var/run/docker.sock",
match: true,
},
{
product: clusterid.ProductDockerDesktop,
kubecontext: "docker-desktop",
dockerHost: "unix://~/.docker/desktop/docker.sock",
match: true,
},
{
product: clusterid.ProductColima,
kubecontext: "colima",
Expand Down

0 comments on commit 0edf8bd

Please sign in to comment.