docker (56) Recv failure: Connection reset by peer

Remember the problem that the docker container cannot access after mapping the host port and the processing process

1. Problem phenomenon

 After the docker container is started correctly, check that the host port has been monitored and you can telnet. But the local curl127.0.0.1 returns curl: (56) Recv failure: Connection reset by peer

 Docker start command docker run -d -p 8083:8080 --name=tomcat1 345867df0879

Host: The firewall and selinux have been closed, and the ipv4 forwarding has been opened.

Inside the container: Tomcat has been listening on port 8080 normally, and the listening address is 0.0.0.0:8080, allowing other machines to access. And can access tomcat normally

Screenshot below:

image.png

2. Processing process

Try to change docker version 19 and 18 are the same, the machine installed is 20

 Searching for various solutions, there is no the same situation. Finally found an introduction to delete and re-add the docker0 bridge to solve the problem

(1) Stop the container and stop the docker service

(2) Rebuild the docker0 bridge

 [root@localhost ~]# yum install bridge-utils -y

[root@localhost ~]# ip link set dev docker0 down

[root@localhost ~]# brctl delbr docker0

[root@localhost ~]# brctl addbr docker0

[root@localhost ~]# ip addr add 172.16.10.1/24 dev docker0

[root@localhost ~]# ip link set dev docker0 up

[root@localhost ~]# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

       valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host 

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 00:15:5d:f0:68:00 brd ff:ff:ff:ff:ff:ff

    inet 192.168.137.129/24 brd 192.168.137.255 scope global eth0

       valid_lft forever preferred_lft forever

    inet6 fe80::215:5dff:fef0:6800/64 scope link 

       valid_lft forever preferred_lft forever

16: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 

    link / ether 3a: 6d: 40: 45: b4: 5a brd ff: ff: ff: ff: ff: ff

    inet 172.16.10.1/24 scope global docker0

       valid_lft forever preferred_lft forever

    inet6 fe80::386d:40ff:fe45:b45a/64 scope link 

       valid_lft forever preferred_lft forever

(3) Restart the docker service and container. Verify that you can access normally.

Conclusion: docker0 bridge and host network communication problem, or container and docker0 bridge communication problem. The specific reasons need to be further explored.

Guess you like

Origin blog.51cto.com/9911287/2608925