如何使用容器的 IP 地址访问在 Docker 容器内运行的网站 [英] How can i access the website running inside a Docker container using IP address of container

查看:73
本文介绍了如何使用容器的 IP 地址访问在 Docker 容器内运行的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何访问在 ip 172.20.128.2 的容器内运行的网站.我不想进行端口转发和使用主机 ip.我知道我可以在主机端口上转发 docker 端口,并且可以使用主机 IP 访问,但我不想这样做.我正在使用 docker 1.10

How can i access the website running inside container at ip 172.20.128.2 .I do not want to do port forwarding and using host ip. I am aware that i can forward docker port on host port and can access using host IP but i do not want to do in this way. I am using docker 1.10

推荐答案

这篇博文解释了从外部访问容器的多种方法.看看四种连接docker容器的方法.

This blog post explains many ways to reach your container from outside. Have a look Four ways to connect a docker container.

确保您的 Web 服务器配置良好,至少使用 -p 选项进行一次测试.

Be sure your web server is well configured testing at least once with -p option.

您也可以使用 --network host 选项进行测试

Also you can test with the --network host option

问候

这篇关于如何使用容器的 IP 地址访问在 Docker 容器内运行的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆