【发布时间】:2016-10-25 05:04:50
【问题描述】:
我已经使用命令启动了一个 docker 容器
sudo docker run -it -P -d plcdimage
该镜像是使用具有指令 EXPOSE 8080 的 Dockerfile 构建的。容器运行一个 jboss 服务器,并在其上部署了一个应用程序。端口映射是:
Command: sudo docker port be1837e849dc
Output: 8080/tcp -> 0.0.0.0:32771
当我尝试使用 url 从映射的主机端口访问容器中 jboss 上运行的 Web 应用程序时:
我收到连接被拒绝错误。以下是命令“netstat -tulpn”的结果
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::9999 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 :::32771 :::* LISTEN -
udp 0 0 0.0.0.0:68 0.0.0.0:* -
我尝试使用 telnet hostip 32771 也导致连接被拒绝。
Docker version 1.12.1
build 23cf638
这可能是什么原因?
提前致谢
【问题讨论】:
-
首先要检查的是你的容器是否真的在监听8080端口。你可以用
docker inspect获取你的容器的IP地址,然后尝试从主机浏览到http://[container-ip]:8080 -
sudo docker ps的结果是什么?
标签: docker dockerfile