Container sees the wrong source IP (always the gateway 172.x) behind published ports.
AdvancedTroubleshootingNetworking, DNS and Compose
Answer
Likely causes → Userland proxy or masquerade replaces client IP, especially on Docker Desktop or with IPv6 to IPv4 translation.
Diagnose → docker logs web shows 172.18.0.1; check "userland-proxy" setting.
Fix → Use --network host for the edge proxy, run the reverse proxy on the host, use PROXY protocol or X-Forwarded-For, disable userland-proxy where acceptable.
Prevent → Terminate TLS at a proxy that adds X-Forwarded-For.
More on Networking, DNS and Compose
`curl: (7) Failed to connect to localhost port 8080: Connection refused` after `docker run -p 8080:80 nginx`.Beginner`Bind for 0.0.0.0:5432 failed: port is already allocated`BeginnerContainers cannot reach the internet: `Temporary failure in name resolution`Advanced`ping` works to IPs but DNS names fail on the default bridge: `ping: bad address 'db'`Beginner`getaddrinfo ENOTFOUND db` in a Compose app.BeginnerCompose: `service "api" depends on undefined service "db"`Beginner