无法访问docker容器内的flask端口,Connection refused
1、通过docker inspect CONTAINERID | grep Address 查看容器的ip[root@master ~]# docker inspect deadfda1b35d | grep Address"LinkLocalIPv6Address": "","SecondaryIPAddresses": null,...
·
1、通过 docker inspect CONTAINERID | grep Address 查看容器的ip
[root@master ~]# docker inspect deadfda1b35d | grep Address
"LinkLocalIPv6Address": "",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"GlobalIPv6Address": "",
"IPAddress": "172.17.0.3",
"MacAddress": "02:42:ac:11:00:03",
"IPAddress": "172.17.0.3",
"GlobalIPv6Address": "",
"MacAddress": "02:42:ac:11:00:03"
2、通过telnet命令测试,发现连接拒绝
[root@master ~]# telnet 172.17.0.3 8788
Trying 172.17.0.3...
telnet: connect to address 172.17.0.3: Connection refused
3、启动容器时,已经映射端口,所以不存在是因为没有-p映射的问题
docker run -it -v /root/soft/docker/lunwen/:/app/ -p 127.0.0.1:8788:8788 --privileged=true 6d64501af04c /bin/bash
4、通过docker ps -a查看,端口映射也是对的
[root@master ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
deadfda1b35d 6d64501af04c "/bin/bash" About an hour ago Up 7 minutes 127.0.0.1:8788->8788/tcp unruffled_cori
5、最终发现,flask启动时,设置的ip为127.0.0.1,改为0.0.0.0就没问题
更多推荐
已为社区贡献3条内容
所有评论(0)