window 无法访问docker_在使用docker工具箱时,无法使用主机(Windows)IP访问Docker VM上的tomcat应用程序...

本文介绍了如何在使用Docker Toolbox环境下,将Tomcat容器应用映射到Windows主机上,并可通过局域网访问。通过在Oracle VirtualBox Manager中设置端口转发规则实现这一目的。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

bd96500e110b49cbb3cd949968f18be7.png

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.

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.

解决方案

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

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值