第一种方式:
通过 --net="host" 直接使用本地网络,容器内的nginx端口也要改成1883
docker run -d --net="host" --name web-ui -v /data/pgms_data/:/usr/share/nginx/html/file -p 1883:1883 web-ui
第二种方式:
重置docker0网卡
今天在测试docker容器时,本来配置的一切都挺顺利,放出我的测试经过:
docker run -d --name web-ui -v /data/pgms_data/:/usr/share/nginx/html/file -p 1883:80 web-ui
然后这个nginx就在后台启动了,我接着使用命令
curl localhost:1883
结果给我报错:curl: (56) Recv failure: Connection reset by peer
防火墙也关闭了,但是还是不行,后来重新设置了网卡,就可以了,解决过程如下:
首先备份原来的docker0配置
ifconfig
ip addr show
将docker0配置记录下来
#首先停止docker
systemctl stop docker
#docker0
ip link set dev docker0 down
#删除docker0网桥
brctl delbr docker0
#增加docker0 网桥
brctl addbr docker0
#增加网卡
ip addr add 172.16.10.1/24 dev docker0
#启用网卡
ip link set dev docker0 up
#重启docker服务
systemctl start docker
#注意:每次重启linux系统之后都要重新再配
- Connection failure docker 问题 resetconnection failure docker问题 connection failure github reset connection reset peer by http_communication_failure communication connection connection reset iis connection internet reset flush temporary resolving failure docker quot connection decoding docker connection仓库refused docker connection_control connection control问题