如何从浏览器访问docker容器中运行的tomcat? [英] How to access tomcat running in docker container from browser?
问题描述
docker pull tomcat
根据主页我已经运行了实例,Tomcat服务器启动了
docker run -it - -p 8888:8080 tomcat:8.0
Tomcat服务器在端口8888上可用。我可以在执行以下命令时,在 boot2docker 中获取响应
curl localhost:8888
但是我想从安装在我的PC上的网络浏览器访问该页面(这是虚拟的Box,那个安装在我的Windows中)。我可以吗?
您可能在VirtualBox设置中缺少端口转发规则。
boot2docker vm>设置>网络> NAT适配器>端口转发
注意最后一个条目:
这样你就有配置整个链: hostPort:virtualBoxPort
then virtualBoxPort:containerPort
,如下图所示:
I am running tomcat in my docker container from the Official Repo.
docker pull tomcat
And as per guidelines stated in the homepage I've run the instance and the Tomcat server is started
docker run -it --rm -p 8888:8080 tomcat:8.0
And Tomcat server is available on the port 8888. I am able to get the response in the boot2docker when I execute the following command
curl localhost:8888
But I would like to access the page from my web browser installed in my PC (which is out of the Virtual Box, the one that is installed in my Windows). Can I? If so how?
You may be missing a port forwarding rule in the VirtualBox settings.
boot2docker vm > settings > Network > NAT adapter > Port forwarding
Note the last entry:
This way you have configured the whole chain: hostPort:virtualBoxPort
then virtualBoxPort:containerPort
, as shown in the following diagram:
这篇关于如何从浏览器访问docker容器中运行的tomcat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!