docker/compose · error

invalid DNS address: %w

Error message

invalid DNS address: %w

What it means

Error "invalid DNS address: %w" thrown in docker/compose.

Source

Thrown at pkg/compose/create.go:381

	// MISC
	resources := getDeployResources(service)
	var logConfig container.LogConfig
	if service.Logging != nil {
		logConfig = container.LogConfig{
			Type:   service.Logging.Driver,
			Config: service.Logging.Options,
		}
	}
	securityOpts, unconfined, err := parseSecurityOpts(p, service.SecurityOpt)
	if err != nil {
		return createConfigs{}, err
	}

	var dnsIPs []netip.Addr
	for _, d := range service.DNS {
		dnsIP, err := netip.ParseAddr(d)
		if err != nil {
			return createConfigs{}, fmt.Errorf("invalid DNS address: %w", err)
		}
		dnsIPs = append(dnsIPs, dnsIP)
	}

	hostConfig := container.HostConfig{
		AutoRemove:     opts.AutoRemove,
		Annotations:    service.Annotations,
		Binds:          binds,
		Mounts:         mounts,
		CapAdd:         service.CapAdd,
		CapDrop:        service.CapDrop,
		NetworkMode:    networkMode,
		Init:           service.Init,
		IpcMode:        container.IpcMode(service.Ipc),
		CgroupnsMode:   container.CgroupnsMode(service.Cgroup),
		ReadonlyRootfs: service.ReadOnly,
		RestartPolicy:  getRestartPolicy(service),
		ShmSize:        int64(service.ShmSize),

View on GitHub (pinned to ddc4b044b6)

Solutions

  1. Correct the dns entry in the compose file to a valid IP address (e.g. 8.8.8.8).
  2. Remove the invalid dns entry and let Docker use its default resolver.

When it happens

Trigger: A 'dns' entry in the service definition contains an IP address that cannot be parsed.

Common situations: Typo in the DNS server address, a hostname instead of an IP, or an empty/whitespace value in the dns list.


AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15). Data as JSON: /api/errors/5bf57ffc3c06131f. Report an issue: GitHub.