Error Running iptables in CentOS on Docker Container

Asked 1 years ago, Updated 1 years ago, 96 views

#iptables-L
FATAL: Could not load/lib/modules/4.9.184-linuxkit/modules.dep: No such file or directory
iptables v1.4.7: can't initialize iptables table `filter': Permission denied (you must be root)
Perhaps iptables or your kernel needs to be upgraded.

I get this error.
After uninstalling iptables, I reinstalled it, but it didn't work.

Centos 6 is placed in the environment docker

>docker-v
Docker version 19.03.5, build 633a0ea

>cat/etc/redhat-release 
CentOS release 6.10 (Final)

cat/proc/version 
Linux version 4.9.184-linuxkit (root@a8c33e955a82) (gcc version 8.3.0 (Alpine 8.3.0) #1 SMP Tue Jul 22:58:16 UTC 2019

iptables --version
iptables v1.4.7

iptables settings

>vi/etc/sysconfig/iptables
*filter
—INPUT DROP [0:0]
—FORWARD DROP [0:0]
—OUTPUT ACCEPT [388:275634]
—RH-Firewall-1-INPUT-[0:0]
—SERVICE - [0:0]
-AINPUT-m state --state NEW-m tcp-p tcp --dport80-j ACCEPT
-AINPUT-m state --state NEW-m tcp-p tcp --dport20-j ACCEPT
-AINPUT-m state --state NEW-m tcp-p tcp --dport22-j ACCEPT
-AINPUT-m state --state NEW-m tcp-p tcp --dport3306-j ACCEPT
-AINPUT-m state --state NEW-m tcp-p tcp --dport3000-j ACCEPT
COMMIT

Why can't firewall be configured?
Please let me know.

centos docker iptables

2022-09-30 15:50

1 Answers

Try adding the --cap-add=NET_ADMIN option to docker run.


2022-09-30 15:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.