本文介绍了无法从浏览器访问Docker tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经启动了一个容器,并打开了一些端口,并尝试从浏览器访问Tomcat的Web界面,但是它不起作用。
I have started a container with some ports open and tries to access the web interface of Tomcat from browser but it's not working.
1)docker run -ti --rm --name server -p 3456:5678 tomcat:8.0 // not working with localhost:3456
2)docker run -ti --rm --name server -expose 8080 tomcat:8.0 //not working localhost:8080
3)docker inspect server // to see the ip:port and tried to access using it as well but no luck
我正在安装docker的情况下使用CentOS7。
I am using CentOS7 with docker instaled.
谢谢
推荐答案
这很简单:
- 不起作用,因为您在绑定到tomcat不使用的容器端口5678(请参阅EXPOSE 命令60aabb354b1b0c9724631d82890ba7e308104d76 / 8.0 / jre7 / Dockerfile rel = noreferrer> Dockerfile )
- 不起作用,因为您未绑定到主机端口(
-p
丢失)
- is not working because you are binding to container port 5678 which is not used by tomcat (see
EXPOSE
commands in Dockerfile) - is not working because you did not bind to a host port (
-p
is missing)
这有效:
docker run -ti --rm --name server -p 9090:8080 tomcat:8.0
在浏览器中打开 localhost:9090
。
这篇关于无法从浏览器访问Docker tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!