diff --git a/cli/command/container/create.go b/cli/command/container/create.go index a2733ccf6042..3faacc382a03 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "io" - "net/netip" "os" "path" "strings" @@ -25,7 +24,6 @@ import ( "github.com/docker/cli/cli/trust" "github.com/docker/cli/internal/jsonstream" "github.com/docker/cli/opts" - "github.com/moby/moby/api/types/container" "github.com/moby/moby/api/types/mount" "github.com/moby/moby/api/types/versions" "github.com/moby/moby/client" @@ -361,10 +359,6 @@ func createContainer(ctx context.Context, dockerCli command.Cli, containerCfg *c } } - if warn := localhostDNSWarning(*hostConfig); warn != "" { - response.Warnings = append(response.Warnings, warn) - } - containerID = response.ID for _, w := range response.Warnings { _, _ = fmt.Fprintln(dockerCli.Err(), "WARNING:", w) @@ -385,19 +379,6 @@ func createContainer(ctx context.Context, dockerCli command.Cli, containerCfg *c return containerID, err } -// check the DNS settings passed via --dns against localhost regexp to warn if -// they are trying to set a DNS to a localhost address. -// -// TODO(thaJeztah): move this to the daemon, which can make a better call if it will work or not (depending on networking mode). -func localhostDNSWarning(hostConfig container.HostConfig) string { - for _, dnsIP := range hostConfig.DNS { - if addr, err := netip.ParseAddr(dnsIP); err == nil && addr.IsLoopback() { - return fmt.Sprintf("Localhost DNS (%s) may fail in containers.", addr) - } - } - return "" -} - func validatePullOpt(val string) error { switch val { case PullImageAlways, PullImageMissing, PullImageNever, "": diff --git a/cli/command/container/create_test.go b/cli/command/container/create_test.go index 6776f9c159f1..3307a3be3f17 100644 --- a/cli/command/container/create_test.go +++ b/cli/command/container/create_test.go @@ -292,16 +292,6 @@ func TestNewCreateCommandWithWarnings(t *testing.T) { args: []string{"image:tag"}, warnings: []string{"warning from daemon", "another warning from daemon"}, }, - { - name: "container-create-localhost-dns", - args: []string{"--dns=127.0.0.11", "image:tag"}, - warning: true, - }, - { - name: "container-create-localhost-dns-ipv6", - args: []string{"--dns=::1", "image:tag"}, - warning: true, - }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { diff --git a/cli/command/container/testdata/container-create-localhost-dns-ipv6.golden b/cli/command/container/testdata/container-create-localhost-dns-ipv6.golden deleted file mode 100644 index bb07a137dcea..000000000000 --- a/cli/command/container/testdata/container-create-localhost-dns-ipv6.golden +++ /dev/null @@ -1 +0,0 @@ -WARNING: Localhost DNS (::1) may fail in containers. diff --git a/cli/command/container/testdata/container-create-localhost-dns.golden b/cli/command/container/testdata/container-create-localhost-dns.golden deleted file mode 100644 index 409082ad6acf..000000000000 --- a/cli/command/container/testdata/container-create-localhost-dns.golden +++ /dev/null @@ -1 +0,0 @@ -WARNING: Localhost DNS (127.0.0.11) may fail in containers.