Why my service couldn't see “localhost” inside Docker

Containers change what “local” means.

← All projects

The problem

An image service needed to recognize the server's owner when a request came from the same machine. Inside Docker, that check always failed.

What I found

Docker's port forwarding hands the container the bridge gateway address, not 127.0.0.1. From inside the container, no request ever looks local.

The fix

Takeaway

Know what the network looks like from inside before trusting an address check.