8
votes

I'm using default docker on windows configuration and I run configure an application like this:

docker run -d -p 8080:80 --name openproject ...

I can access the application using browser, but in fiddler I can't see traffic to the docker container. I see other traffic, so I assume the browser has correct proxy settings.

I've set proxy in docker settings to fiddler (http://127.0.0.1:8888), but still nothing from the container is visible to fiddler.

2
'fiddler I can't see traffic to the docker container' -- What's the client application that sends traffic /into/ Docker? If it's a browser, what URL are you using? - EricLaw
Clients are a browser and powershell. Url is "localhost:8080" and "127.0.0.1:8080". Works in the browser and powershell, though fiddler does not see it. - mrówa
Powershell and .NET don't proxy requests to localhost/127.0.0.1, regardless of whether you specify a proxy. Requests from Chrome/Firefox absolutely should be shown. See groups.google.com/forum/#!topic/httpfiddler/SsZnGxdxklg - EricLaw
You misunderstand: .NET doesn't proxy requests whose URLs target 127.0.0.1 and localhost. (This isn't about the URL of the proxy, it's about the URL of the target resource). visualstudio.uservoice.com/forums/121579-visual-studio-ide/… - EricLaw
Alternatively, use localhost.fiddler as the address you use to call the Docker container. Fiddler will get that address and automatically turn it into localhost. - EricLaw

2 Answers

3
votes

If you're trying to see traffic exiting the container, add this to your Dockerfile:

ENV http_proxy "http://host.docker.internal:8888/"
ENV https_proxy "http://host.docker.internal:8888/"

The http_proxy and https_proxy environment variables should be lowercase in a Linux container, contrary to what some of the Docker docs say (https://unix.stackexchange.com/questions/212894/whats-the-right-format-for-the-http-proxy-environment-variable-caps-or-no-ca)

host.docker.internal shortcuts you to the internal IP address used by the host (https://docs.docker.com/docker-for-windows/networking/).

Port 8888 is whatever port Fiddler is listening on in the host.

2
votes

You can do that by finding out the IP-address of your Docker host (the VM running on Hyper-V). Just run "ipconfig" on the command shell.

The default IP address is probably 10.0.75.1 (at least it is on my machine).

So instead of http://localhost:8080 browse to http://10.0.75.1:8080 and fiddler will pick up the traffic.