Docker starts the container and reports an error

insert image description here

error message


[root@Dream soft]# docker run  -it -d -p 8080:8080 tomcat
eec9fab6b9ca06d2bbf1467aef05d8020ee60448978e10ac20c38888934f0a0b
docker: Error response from daemon: driver failed programming external connectivity on endpoint hungry_euclid (163242f0079e7260acb3a98ceef930b9629ed0e79407193adf080fdf080fe0ad):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8080 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
 (exit status 1)).

The error message indicates that Docker had a problem setting up port forwarding for the container. It tries to use the iptables command to set up the NAT rules, but seems to encounter some errors.

This problem may be caused by the iptables package not being installed or configured correctly. You can try to reinstall the iptables package to solve the problem. On CentOS systems, iptables can be reinstalled with the following command:

sudo yum reinstall iptables

Once done, try running the Docker container again and check if you still get the same error.

Also, make sure you really don't have another service or process using port 8080 to avoid conflicts. You can lsofcheck if the port is in use with the command:

sudo lsof -i :8080

If the port is already occupied, you can choose to replace an unoccupied port to run the container, or stop the process occupying the port.
Then restart the container, if it still fails to start, then our firewall has been restarted at this time, resulting in a change in the security mechanism of docker, we only need to restart docker, but note that restarting docker will also bring risks to other containers
insert image description here

Guess you like

Origin blog.csdn.net/weixin_53742691/article/details/132000550