Why my service couldn't see “localhost” inside Docker
Containers change what “local” means.
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
- Moved the service off Docker onto a host systemd service that starts on boot — its dependencies were minimal, so the container added little value.
- Kept a second sign-in path, a signed token, that works the same locally or remotely.
- Disabled the old container entry so it couldn't be recreated by accident.
Takeaway
Know what the network looks like from inside before trusting an address check.