我已经启动了一个带有某些端口的容器,并试图从浏览器访问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 Instaled使用centos7。
谢谢
这很简单:
- 因为您与Tomcat未使用的容器端口5678绑定(请参阅Dockerfile中的
EXPOSE
命令) - 因为您没有绑定到主机端口(
-p
缺少)
而无法工作
这有效:
docker run -ti --rm --name server -p 9090:8080 tomcat:8.0
在您的浏览器中打开localhost:9090
。