10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dockerコンテナ内で service iptables stop/status をエラーにしない

Last updated at Posted at 2014-10-21

セントス6など前提で。

CAP_NET_ADMIN ケーパビリティを与える

$ docker run --cap-add=NET_ADMIN --rm -ti hoge_image /bin/bash

IPTABLES_MODULES_UNLOAD=no/etc/sysconfig/iptables-config に書き込む

bash-4.1# echo 'IPTABLES_MODULES_UNLOAD=no' >> /etc/sysconfig/iptables-config
bash-4.1# service iptables stop
iptables: Setting chains to policy ACCEPT: nat filter      [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
bash-4.1# service iptables status
Table: nat
Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
num  target     prot opt source               destination         

Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         

Serverspec のお供にどうぞ。Docker内ではスキップしてる人が多そうだが。

10
9
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?