docker/cli · error · invalidParameter

conflicting options: cannot specify both --ip and per-networ

Error message

conflicting options: cannot specify both --ip and per-network IPv4 address

What it means

Raised in applyContainerOptions (opts.go:818) when a static IPv4 address is specified both via --ip and via the advanced per-network syntax (--network name=...,ip=...). An endpoint can only have one IPv4 IPAM address, so the CLI rejects the ambiguous combination.

Source

Thrown at cli/command/container/opts.go:819

		}
		endpoints[n.Target] = ep
	}
	if hasUserDefined && hasNonUserDefined {
		return nil, invalidParameter(errors.New("conflicting options: cannot attach both user-defined and non-user-defined network-modes"))
	}
	return endpoints, nil
}

func applyContainerOptions(n *opts.NetworkAttachmentOpts, copts *containerOptions) error { //nolint:gocyclo
	// TODO should we error if _any_ advanced option is used? (i.e. forbid to combine advanced notation with the "old" flags (`--network-alias`, `--link`, `--ip`, `--ip6`)?
	if len(n.Aliases) > 0 && copts.aliases.Len() > 0 {
		return invalidParameter(errors.New("conflicting options: cannot specify both --network-alias and per-network alias"))
	}
	if len(n.Links) > 0 && copts.links.Len() > 0 {
		return invalidParameter(errors.New("conflicting options: cannot specify both --link and per-network links"))
	}
	if n.IPv4Address.IsValid() && copts.ipv4Address != nil {
		return invalidParameter(errors.New("conflicting options: cannot specify both --ip and per-network IPv4 address"))
	}
	if n.IPv6Address.IsValid() && copts.ipv6Address != nil {
		return invalidParameter(errors.New("conflicting options: cannot specify both --ip6 and per-network IPv6 address"))
	}
	if n.MacAddress != "" && copts.macAddress != "" {
		return invalidParameter(errors.New("conflicting options: cannot specify both --mac-address and per-network MAC address"))
	}
	if len(n.LinkLocalIPs) > 0 && copts.linkLocalIPs.Len() > 0 {
		return invalidParameter(errors.New("conflicting options: cannot specify both --link-local-ip and per-network link-local IP addresses"))
	}
	if copts.aliases.Len() > 0 {
		n.Aliases = make([]string, copts.aliases.Len())
		copy(n.Aliases, copts.aliases.GetSlice())
	}
	// For a user-defined network, "--link" is an endpoint option, it creates an alias. But,
	// for the default bridge it defines a legacy-link.
	if container.NetworkMode(n.Target).IsUserDefined() && copts.links.Len() > 0 {
		n.Links = make([]string, copts.links.Len())

View on GitHub (pinned to e9452d6e78)

Solutions

  1. Specify the address only in the advanced syntax: --network name=mynet,ip=172.20.0.5
  2. Or remove the per-network ip= and use --ip with a plain --network mynet
  3. Ensure the chosen address falls within the network's subnet (the network must have a user-configured subnet for static IPs)

Example fix

// before
docker run --ip 172.20.0.5 --network name=appnet,ip=172.20.0.6 nginx
// after
docker run --network name=appnet,ip=172.20.0.5 nginx

When it happens

Trigger: `docker run --ip 172.20.0.5 --network name=mynet,ip=172.20.0.6 ...` — n.IPv4Address is valid from the advanced option while copts.ipv4Address is also set.

Common situations: Automation that appends --ip globally while templates already embed ip= in the --network option; migrating single-network commands to multi-network advanced syntax without removing the old flag.

Related errors


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/f15ac3d1496ac8bb.json. Report an issue: GitHub.