LoginSignup
11
9

More than 3 years have passed since last update.

iptables in docker

Last updated at Posted at 2014-06-12

最近 docker 良く触っています。そうすると仕事柄 iptables を docker container 内で使いたくなることもある訳で。

結論から。「iptables LOG target は docker container 内では動作しない。」

そして「iptables自体は動作する。」

iptables のデバッグをするときには LOG target を仕込んでデバッグをするのが一般的かと思います。docker 内で iptables の動作確認をしつつルールを作ろうとしていたのですが、ログが出ないので作業が進まない!

原因をたどってみると、あっけないものでした。Linux net/netfilter/xt_LOG.c の ipt_log_packet() に次のように書いてあります。出力が無効化されています。今の最新版(mainline 3.15 HEAD)でもこのままなので、漏れなく無効でしょう。

    /* FIXME: Disabled from containers until syslog ns is supported */
    if (!net_eq(net, &init_net))
        return;

というわけで、コンテナ外でルールを作り終わってからコンテナ内に持ち込むことになりそうです。

あ、ちなみに iptables のルールを入れるには権限が必要なので、docker run の --privileged 引数を付けて起動します。


現在はサポート追加されているようです。

11
9
0

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
11
9