diff --git a/integration/container/nat_test.go b/integration/container/nat_test.go index 5567e01ab39d2..0b25d8591fafb 100644 --- a/integration/container/nat_test.go +++ b/integration/container/nat_test.go @@ -29,7 +29,7 @@ func TestNetworkNat(t *testing.T) { startServerContainer(t, msg, 8080) endpoint := getExternalAddress(t) - conn, err := net.Dial("tcp", net.JoinHostPort(endpoint.String(), "8080")) + conn, err := net.Dial("tcp4", net.JoinHostPort(endpoint.String(), "8080")) assert.NilError(t, err) defer conn.Close() @@ -46,7 +46,7 @@ func TestNetworkLocalhostTCPNat(t *testing.T) { msg := "hi yall" startServerContainer(t, msg, 8081) - conn, err := net.Dial("tcp", "localhost:8081") + conn, err := net.Dial("tcp4", "localhost:8081") assert.NilError(t, err) defer conn.Close() @@ -70,7 +70,7 @@ func TestNetworkLoopbackNat(t *testing.T) { ctx := context.Background() cID := container.Run(ctx, t, client, - container.WithCmd("sh", "-c", fmt.Sprintf("stty raw && nc -w 1 %s 8080", endpoint.String())), + container.WithCmd("sh", "-c", fmt.Sprintf("stty raw && nc -4 -w 1 %s 8080", endpoint.String())), container.WithTty(true), container.WithNetworkMode("container:"+serverContainerID), ) diff --git a/integration/container/rename_test.go b/integration/container/rename_test.go index 689a37fc3266d..4e21ecb561599 100644 --- a/integration/container/rename_test.go +++ b/integration/container/rename_test.go @@ -159,7 +159,7 @@ func TestRenameAnonymousContainer(t *testing.T) { networkName: {}, } c.HostConfig.NetworkMode = containertypes.NetworkMode(networkName) - }, container.WithCmd("ping", count, "1", container1Name)) + }, container.WithCmd("ping", "-4", count, "1", container1Name)) poll.WaitOn(t, container.IsInState(ctx, client, cID, "exited"), poll.WithDelay(100*time.Millisecond)) inspect, err := client.ContainerInspect(ctx, cID) diff --git a/integration/container/run_linux_test.go b/integration/container/run_linux_test.go index 6a8322d9d8b64..e0537479d7b51 100644 --- a/integration/container/run_linux_test.go +++ b/integration/container/run_linux_test.go @@ -85,15 +85,15 @@ func TestHostnameDnsResolution(t *testing.T) { const ( hostname = "foobar" + netName = "foobar-net" ) // using user defined network as we want to use internal DNS - netName := "foobar-net" net.CreateNoError(context.Background(), t, client, netName, net.WithDriver("bridge")) cID := container.Run(ctx, t, client, func(c *container.TestContainerConfig) { c.Config.Hostname = hostname - c.HostConfig.NetworkMode = containertypes.NetworkMode(netName) + c.HostConfig.NetworkMode = netName }) poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond)) @@ -104,7 +104,7 @@ func TestHostnameDnsResolution(t *testing.T) { // Clear hosts file so ping will use DNS for hostname resolution res, err := container.Exec(ctx, client, cID, - []string{"sh", "-c", "echo 127.0.0.1 localhost | tee /etc/hosts && ping -c 1 foobar"}) + []string{"sh", "-c", "echo 127.0.0.1 localhost | tee /etc/hosts && ping -4 -c 1 foobar"}) assert.NilError(t, err) assert.Check(t, is.Equal("", res.Stderr())) assert.Equal(t, 0, res.ExitCode)