Traefik Docker Compose example

As per example for Docker Compose found here: Traefik Docker Documentation - Traefik

I should see the X-Real-Ip from my local network 192.168.0.x

However I'm seeing IP addresses from docker network, what is the problem?

Hostname: dac61fc13602
IP: 127.0.0.1
IP: ::1
IP: 172.21.0.2
RemoteAddr: 172.21.0.3:55350
GET / HTTP/1.1
Host: whoami.localhost
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.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
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8,lt;q=0.7
Cache-Control: max-age=0
Dnt: 1
Sec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "Windows"
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
X-Forwarded-For: 172.21.0.1
X-Forwarded-Host: whoami.localhost
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Server: d743d4f46f2f
X-Real-Ip: 172.21.0.1

How do you run Docker?

I'm running it on my windows machine, by executing

docker compose up -d

Docker is a Linux tool, so it doesn't simply run on Windows. It might work with Docker Desktop or WSL2, but both use a VM to run Linux to run Docker. Because of the extra layer the IP packets are routed and IP addresses are changed.

Makes sense. Just tried running on linux VPS and it does actually show my real IP address.

However, when running in docker stack

docker stack deploy -c docker-compose.yaml traefik

It shows docker host IP address. Is it because of a swarm mode enabled for stack to operate? What is the solution?

Just 2 days ago, 6 posts down, this was recently discussed.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.