Skip to content

Commit

Permalink
fix: allow docker host config via env variable (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
davemooreuws authored Aug 14, 2024
1 parent b6097ac commit 40df95f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 79 deletions.
66 changes: 0 additions & 66 deletions pkg/docker/wsl.go

This file was deleted.

16 changes: 3 additions & 13 deletions pkg/project/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/nitrictech/cli/pkg/docker"
"github.com/nitrictech/cli/pkg/netx"
"github.com/nitrictech/cli/pkg/project/runtime"
"github.com/nitrictech/nitric/core/pkg/env"
"github.com/nitrictech/nitric/core/pkg/logger"
)

Expand Down Expand Up @@ -322,22 +323,11 @@ func (s *Service) RunContainer(stop <-chan bool, updates chan<- ServiceRunUpdate
}

if goruntime.GOOS == "linux" {
isWSL, _ := docker.IsDockerRunningInWSL2(dockerClient)

// default docker host ip
dockerHostIP := "172.17.0.1"

if isWSL {
wslEth0IP := docker.GetNonLoopbackLocalIPForWSL()

if wslEth0IP != "" {
dockerHostIP = wslEth0IP
}
}
dockerHost := env.GetEnv("NITRIC_DOCKER_HOST", "172.17.0.1")

// setup host.docker.internal to route to host gateway
// to access rpc server hosted by local CLI run
hostConfig.ExtraHosts = []string{"host.docker.internal:" + dockerHostIP}
hostConfig.ExtraHosts = []string{"host.docker.internal:" + dockerHost.String()}
}

randomPort, _ := netx.TakePort(1)
Expand Down

0 comments on commit 40df95f

Please sign in to comment.