Why Docker Adds 169.254.1.1 IP Address
Docker may assign an IP address in the 169.254.x.x range due to the Automatic Private IP Addressing (APIPA) mechanism. This typically happens when a network interface fails to obtain an IP address from a DHCP server or when specific configurations in Docker's networking setup lead to the use of link-local addresses.
Example
If you inspect a Docker network or container, you might see:
docker network inspect bridge
Copy
Output:
{
"Subnet": "169.254.1.0/24",
"Gateway": "169.254.1.1"
}
Copy
Causes of 169.254.x.x Addresses in Docker
DHCP Failure: If Docker's network bridge cannot communicate with a DHCP server, it assigns a link-local address (169.254.x.x) to ensure basic connectivity.
Custom Network Configuration: Manually configuring Docker networks with subnets like 169.254.x.x/16 can result in this behavior.
Default Link-Local Route: Some systems automatically add routes for 169.254.x.x to support fallback communication when no other IP is available.
Solutions
Verify DHCP Configuration: Ensure that the Docker bridge network can access a valid DHCP server or has a static IP configuration.
docker network inspect bridge
Copy
Avoid Using Link-Local Subnets: If you manually configured a custom subnet, avoid using 169.254.x.x as it is reserved for APIPA.
Remove Unnecessary Routes: If the route is not required, you can delete it:
sudo route del -net 169.254.0.0 gw 0.0.0.0
Copy
Reconfigure Docker Networking: Use a valid private IP range (e.g., 192.168.x.x) for your Docker networks:
docker network create --subnet=192.168.1.0/24 my_custom_network
Copy
By addressing these configurations, you can prevent Docker from assigning 169.254.x.x addresses unnecessarily and ensure proper networking functionality for your containers
1
更多推荐
所有评论(0)