使用 docker 工具箱时无法使用主机(windows)IP 访问 Docker VM 上的 tomcat 应用程序 [英] Not able to access tomcat application on Docker VM with host(windows) IP while using docker toolbox

查看:25
本文介绍了使用 docker 工具箱时无法使用主机(windows)IP 访问 Docker VM 上的 tomcat 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 docker 工具箱在我的 Windows 系统上运行 docker.我使用命令 docker run -it --rm -p 8888:8080 tomcat:8.0 运行了 tomcat 容器.根据文档,我应该能够使用 http://localhost:8888 访问 tomcat,但这不起作用.

相反,我可以使用 docker-machine ip 访问 tomcat 应用程序,它是 http://192.168.99.100:8888.

I am running docker on my windows system using docker toolbox. I ran tomcat container using command docker run -it --rm -p 8888:8080 tomcat:8.0. As per documentation I should be able to access tomcat using http://localhost:8888, but this is not working.

Rather, I can access the tomcat app using docker-machine ip which is http://192.168.99.100:8888.

但这不是我需要的.我需要通过网络从我的系统外部访问 tomcat 容器应用程序.那么,如何将 tomcat 应用程序映射到我的 Windows 主机系统?

在谷歌搜索时,我可以看到 boot2docker vm 的端口转发选项.但是,我再次没有使用 boot2docker.我正在使用 docker 工具箱.

But this is not what I need. I need to access the tomcat container app from outside my system itself, through the network. So, how do I map tomcat application to my windows host system ?

While googling around, I could see an option of port-forwarding for boot2docker vm. But, again I am not using boot2docker. I am using docker toolbox.

推荐答案

最后,我找到了添加端口转发规则的位置.打开 oracle VirtualBox 管理器.转到设置-->网络-->端口转发..

Finally, I was able to find where to add the port-forwarding rule. Open the oracle VirtualBox Manager. Go to Settings-->Network --> Port Forwarding..

这里 1 条规则已可用于 ssh.所以我用以下配置为此添加了另一个规则:主机IP:主机端口=> 127.0.0.1:9999访客IP:访客端口=> :8888

Here 1 rule is already available for ssh. So I added another rule for this with below configurations: HostIP:HostPort=> 127.0.0.1:9999 GuestIP:GuestPort=> :8888

所以现在如果我调用 http://localhost:9999 ,它会被转发到 => docker-machine:8888然后从那里转发到 => tomcatVM:8080.

So now if I invoke http://localhost:9999 , it is forwarded to => docker-machine:8888 and from there it is forwarded to => tomcatVM:8080.

这篇关于使用 docker 工具箱时无法使用主机(windows)IP 访问 Docker VM 上的 tomcat 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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