diff --git a/pkg/drivers/kic/oci/network.go b/pkg/drivers/kic/oci/network.go index 6114345d403ed7d322f02df75b74e65cba9f5630..4fd691d1e041667d05ebece95ff010abc3c7a833 100644 --- a/pkg/drivers/kic/oci/network.go +++ b/pkg/drivers/kic/oci/network.go @@ -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") } diff --git a/test/integration/fn_mount_cmd_test.go b/test/integration/fn_mount_cmd_test.go index a5de842e924646dc93d2104de4b1ff604e29214b..a9599de53606d84e7b0ffbfa52287c3e8eddd575 100644 --- a/test/integration/fn_mount_cmd_test.go +++ b/test/integration/fn_mount_cmd_test.go @@ -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 }