Docker 18.03无法在overlay网络指定静态IP 10.0.7.2创建容器咨询
Let’s break down exactly what’s happening here and why your static IP assignment stopped working after the upgrade:
What’s Using 10.0.7.2?
Starting with Docker 17.06 (which includes the 18.03 version you’re using), when you create an overlay network like mynet, Docker automatically reserves two key IP addresses in your subnet:
10.0.7.1: The network gateway (you already identified this)10.0.7.2: This IP is allocated to Docker’s internal network management endpoint for the overlay network. It’s used to handle cross-node container communication, service discovery, and underlying VXLAN traffic routing between Docker nodes. Even on a single-node setup, this reservation applies—think of it as a backend proxy IP Docker relies on to keep the overlay network stable and functional.
You can confirm this yourself by running:
docker network inspect mynet
Check the IPAM section in the output, and you’ll see 10.0.7.2 listed as a reserved IP or linked to an internal Docker network component.
Why Did This Start Happening After the Upgrade?
Docker 17.05 didn’t have this reservation policy for overlay networks. The change was introduced in later versions to support more robust swarm networking features: improved ingress routing, stable service VIPs, and more reliable cross-node network performance. By reserving x.x.x.2 for internal use, Docker eliminates conflicts between user-assigned container IPs and the critical network infrastructure that keeps overlay networks running smoothly.
How to Fix Your Static IP Issue?
You have two simple, reliable options:
- Use an unreserved static IP: Pick any IP from your subnet that’s not
10.0.7.1or10.0.7.2(e.g.,10.0.7.3,10.0.7.4, etc.). All these addresses are available for container assignment. - Verify reserved IPs upfront: Before assigning static IPs, always run
docker network inspect mynetto check the reserved range—this avoids future conflicts with Docker’s internal network components.
内容的提问来源于stack exchange,提问作者Nitish Mowall

