如何查看 fiddler 中的 http 请求到 Windows 上的 docker 容器?

mró*_*ówa 8 http fiddler docker

我在 Windows 配置上使用默认 docker,我运行配置这样的应用程序:

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

我可以使用浏览器访问应用程序,但在 fiddler 中我看不到 docker 容器的流量。我看到其他流量,所以我假设浏览器有正确的代理设置。

我已经在 docker 设置中将代理设置为 fiddler ( http://127.0.0.1:8888 ),但容器中仍然没有任何东西对 fiddler 可见。

小智 7

如果您尝试查看退出容器的流量,请将其添加到您的 Dockerfile 中:

ENV http_proxy "http://host.docker.internal:8888/"
ENV https_proxy "http://host.docker.internal:8888/"
Run Code Online (Sandbox Code Playgroud)

http_proxy 和 https_proxy 环境变量在 Linux 容器中应为小写,这与某些 Docker 文档所说的相反(https://unix.stackexchange.com/questions/212894/whats-the-right-format-for-the- http-proxy-environment-variable-caps-or-no-ca

host.docker.internal 将您快捷地指向主机使用的内部 IP 地址 ( https://docs.docker.com/docker-for-windows/networking/ )。

端口 8888 是 Fiddler 在主机中监听的端口。(8888 是默认值。)


Wol*_*ang 2

您可以通过查找 Docker 主机(在 Hyper-V 上运行的虚拟机)的 IP 地址来做到这一点。只需在命令 shell 上运行“ipconfig”即可。

默认IP地址可能是10.0.75.1(至少在我的机器上是这样)。

因此,浏览http://10.0.75.1:8080而不是http://localhost:8080,fiddler 将获取流量。