Docker – 从容器修改主机的IPTABLES

前端之家收集整理的这篇文章主要介绍了Docker – 从容器修改主机的IPTABLES前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我想运行一个带有中央日志和fail2ban服务的docker容器来防止dos / ddos​​攻击.

我有一个问题是运行具有这种功能的容器,它也可以修改主机iptables.

有一个项目ianblenke/docker-fail2ban然而它不起作用……

赋予容器标志特权只允许我控制此容器上的iptables.有没有办法通过容器控制主机iptables?

问候.

最佳答案
默认情况下,Docker容器在隔离的网络命名空间内运行,在该命名空间中,它们无法访问主机网络配置(包括iptables).

如果希望容器能够修改主机的网络配置,则需要将–net = host选项传递给docker run.从docker-run(1)手册页:

  1. --net="bridge"
  2. Set the Network mode for the container
  3. 'bridge': creates a new network stack for the container on the docker bridge
  4. 'none': no networking for this container
  5. 'container:': reuses another container network stack
  6. 'host': use the host network stack inside the container.
  7. Note: the host mode gives the container full access to
  8. local system services such as D-bus and is therefore
  9. considered insecure.

您需要同时运行–privileged和–net = host.

猜你在找的Docker相关文章