Docker Community Forums

Share and learn in the Docker community.

Iptables error while running any container

if I try to run any image I get an error like this

docker run -d -p 8000:8000 -p 9000:9000 --name=portainer1 --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

docker: Error response from daemon: driver failed programming    external connectivity on endpoint portainer1 (85c113c0416564a2e9978fcf77a045f57abe661535efdaf8e4df1efdb5eca1dd):  (iptables failed: iptables --wait -t filter -A DOCKER ! -i docker0 -o docker0 -p tcp -d --dport 9000 -j ACCEPT: iptables: No chain/target/match by that name.

(exit status 1)).

I restarted the docker deamon and tried again but it didnt work

I then tried the solutions suggested in this SO answer

I cleared the iptable chain and restarted docker but it didnt work still getting the same error

what am I doing wrong?

I am running Ubuntu 20.04

I believe the issue is within this lines:

iptables -t filter -F

iptables -t filter -X

which indeeds clear all chains. One possible solution is to launch the docker daemon after the iptables setup script. Otherwise you will need to explicitly removes chains you’re interested in.