Get client ip when using bridge network

Is it possible to get the client (actual user, real user ip) ip when using the default bridge network.
This is what I’m getting when using the default bridge:

  • RemoteIpAddress: ::ffff:172.18.0.1
  • LocalIpAddress: ::ffff:172.18.0.2
  • RemotePort: 43582
  • LocalPort: 8080

so looks like the RemoteIP is the docker Gateway ip.

or if I deploy mendhak/http-https-echo:latest container and access it I’ll get this result:

"path": "/",
  "headers": {
    "host": "localhost:32768",
    "connection": "keep-alive",
    "cache-control": "max-age=0",
    "sec-ch-ua": "\"Chromium\";v=\"134\", \"Not:A-Brand\";v=\"24\", \"Google Chrome\";v=\"134\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "upgrade-insecure-requests": "1",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
    "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
    "sec-fetch-site": "none",
    "sec-fetch-mode": "navigate",
    "sec-fetch-user": "?1",
    "sec-fetch-dest": "document",
    "accept-encoding": "gzip, deflate, br, zstd",
    "accept-language": "en-GB,en-US;q=0.9,en;q=0.8,fr;q=0.7,ro;q=0.6,ru;q=0.5",
    "if-none-match": "W/\"491-Al2P89CPfEKyB6f5LMwZZQyz9CE\""
  },
  "method": "GET",
  "body": "",
  "fresh": false,
  "hostname": "localhost",
  "ip": "::ffff:172.17.0.1",
  "ips": [],
  "protocol": "http",
  "query": {},
  "subdomains": [],
  "xhr": false,
  "os": {
    "hostname": "b0f28db19992"
  },
  "connection": {}

as you can see there’s no additional information in the headers related to the actual real IP,

So is docker not sending this IP info at all ?

Turns out on this only an issue on docker desktop,
on my debian VM this is not an issue, I’m getting the client IP in the x-forwarded-for

You could check this feature request: Original ip is not passed to containers ... · Issue #157 · docker/roadmap · GitHub

As far as I remember, getting the real IP in Docker Desktop is not possible because of its implementation, but I haven’t read all the comments in the roadmap. Docker Desktop is for development, so usually the real IP doesn’t matter, but it is true, it could matter when you want to test if getting the real IP in your software works or not.

I’m going to move the topic to the Docker Desktop category. Thanks for sharing the new observation.