提交 69d21df7 编写于 作者: P Priya Wadhwa

make sure we use custom network if it exists

上级 3b5f9734
...@@ -33,7 +33,7 @@ import ( ...@@ -33,7 +33,7 @@ import (
func RoutableHostIPFromInside(ociBin string, containerName string) (net.IP, error) { func RoutableHostIPFromInside(ociBin string, containerName string) (net.IP, error) {
if ociBin == Docker { if ociBin == Docker {
if runtime.GOOS == "linux" { if runtime.GOOS == "linux" {
return dockerGatewayIP() return dockerGatewayIP(containerName)
} }
// for windows and mac, the gateway ip is not routable so we use dns trick. // for windows and mac, the gateway ip is not routable so we use dns trick.
return digDNS(ociBin, containerName, "host.docker.internal") return digDNS(ociBin, containerName, "host.docker.internal")
...@@ -60,8 +60,13 @@ func digDNS(ociBin, containerName, dns string) (net.IP, error) { ...@@ -60,8 +60,13 @@ func digDNS(ociBin, containerName, dns string) (net.IP, error) {
// dockerGatewayIP gets the default gateway ip for the docker bridge on the user's host machine // dockerGatewayIP gets the default gateway ip for the docker bridge on the user's host machine
// gets the ip from user's host docker // gets the ip from user's host docker
func dockerGatewayIP() (net.IP, error) { func dockerGatewayIP(profile string) (net.IP, error) {
rr, err := runCmd(exec.Command(Docker, "network", "ls", "--filter", "name=bridge", "--format", "{{.ID}}")) // check if using custom network first
network := "bridge"
if networkExists(profile) {
network = profile
}
rr, err := runCmd(exec.Command(Docker, "network", "ls", "--filter", fmt.Sprintf("name=%s", network), "--format", "{{.ID}}"))
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "get network bridge") return nil, errors.Wrapf(err, "get network bridge")
} }
......
...@@ -111,8 +111,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { // no ...@@ -111,8 +111,7 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { // no
// Block until the mount succeeds to avoid file race // Block until the mount succeeds to avoid file race
checkMount := func() error { checkMount := func() error {
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "findmnt -T /mount-9p | grep 9p")) _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "findmnt -T /mount-9p | grep 9p"))
t.Log(rr.Output())
return err return err
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册