Skip to content

Commit

Permalink
docker: recognize docker desktop for linux socket location
Browse files Browse the repository at this point in the history
Fixes #5812.
  • Loading branch information
nicksieger committed May 17, 2022
1 parent 3d72875 commit 5be1699
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions internal/docker/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,22 @@ func TestProvideClusterProduct(t *testing.T) {
BuildToKubeContexts: []string{"docker-desktop-me", "docker-desktop-me"},
},
},
{
env: clusterid.ProductDockerDesktop,
runtime: container.RuntimeDocker,
// Set DOCKER_HOST here to mimic docker client discovering socket from desktop-linux context
osEnv: map[string]string{
"DOCKER_HOST": "unix:///home/tilt/.docker/desktop/docker.sock",
},
expectedCluster: Env{
Client: hostClient{Host: "unix:///home/tilt/.docker/desktop/docker.sock"},
BuildToKubeContexts: []string{"docker-desktop-me"},
},
expectedLocal: Env{
Client: hostClient{Host: "unix:///home/tilt/.docker/desktop/docker.sock"},
BuildToKubeContexts: []string{"docker-desktop-me", "docker-desktop-me"},
},
},
{
env: clusterid.ProductRancherDesktop,
runtime: container.RuntimeDocker,
Expand Down
6 changes: 5 additions & 1 deletion internal/docker/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ func isDefaultHost(e Env) bool {
host == "npipe:////./pipe/docker_engine" ||

// https://github.com/moby/moby/blob/master/client/client_unix.go#L6
host == "unix:///var/run/docker.sock"
host == "unix:///var/run/docker.sock" ||

// Docker Desktop for Linux - socket is in ~/.docker/desktop/docker.sock
(strings.HasPrefix(host, "unix://") && strings.HasSuffix(host, "/.docker/desktop/docker.sock"))

if isStandardHost {
return true
}
Expand Down

0 comments on commit 5be1699

Please sign in to comment.