Skip to content

Commit

Permalink
Find a proper docker ipc socket path on darwin
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Litvinov <jnashicq@gmail.com>
  • Loading branch information
Zensey committed Jan 26, 2024
1 parent 92875ec commit 0fda659
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions myst/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"io"
"log"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"
Expand All @@ -24,6 +26,7 @@ import (
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/strslice"
"github.com/docker/docker/client"

"github.com/docker/go-connections/nat"
errors2 "github.com/pkg/errors"

Expand Down Expand Up @@ -60,6 +63,18 @@ type Manager struct {
}

func NewManager(model *model.UIModel) (*Manager, error) {

if runtime.GOOS == "darwin" {
// Prefer DOCKER_HOST, don't override it
_, hasDockerHost := os.LookupEnv("DOCKER_HOST")
if !hasDockerHost {
if _, err := os.Stat("/var/run/docker.sock"); os.IsNotExist(err) {
// path does not exist
os.Setenv("DOCKER_HOST", "unix://"+filepath.Join(utils.GetUserProfileDir(), ".docker/run/docker.sock"))
}
}
}

dc, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
return nil, errors2.Wrap(err, ErrCouldNotConnect.Error())
Expand Down

0 comments on commit 0fda659

Please sign in to comment.