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

make sure we use custom network if it exists

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