从浏览器不能访问的Docker的Tomcat
我已经打开了一些端口打开的容器,并试图从浏览器访问Tomcat的Web界面,但它不工作。
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。
谢谢
这很简单:
- 是不工作的,因为你绑定到tomcat没有使用的容器端口5678(请参阅
EXPOSE
命令) - 不工作,因为你没有绑定到主机端口(
-p
丢失)
这工作:
docker run -ti --rm --name server -p 9090:8080 tomcat:8.0
在浏览器中打开localhost:9090
。