コンテナがデフォルトのBridgeネットワークを使用した場合、ホストマシン外部への転送(フォワーディング)は拒否されています。ホストマシン外部への転送(フォワーディング)を有効にするため、以下対応が必要です。
Enable forwarding from Docker containers to the outside world
By default, traffic from containers connected to the default bridge network is not forwarded to the outside world. To enable forwarding, you need to change two settings. These are not Docker commands and they affect the Docker host’s kernel.
- Configure the Linux kernel to allow IP forwarding.
$ sysctl net.ipv4.conf.all.forwarding=1
- Change the policy for the
iptables
FORWARD
policy fromDROP
toACCEPT
.
$ sudo iptables -P FORWARD ACCEPT
These settings do not persist across a reboot, so you may need to add them to a start-up script.
再起動した場合にも設定が反映されるように起動スクリプトに上記2つのコマンドを追加する必要が有ります。