Not getting correct ip in nginx/containers

Expected behavior

See my real ip (or an X-FORWARDED-FOR header): ex:

Actual behavior

Instead I see, which is not my host’s ip.


Steps to reproduce the behavior

  1. HOST: docker run --rm --name nginx-test -p 8080:80 nginx
  2. HOST: curl localhost:8080
  3. You’ll see an ip in the logs with something like, take note of that.

This is not the ip address of the actual machine that made the call. For debuggers that call back to the originating ip (such as php xdebug) this means docker cannot be used to debug anything. I would expect to see an IP of the original machine (such as a truly remote host).