【问题标题】:running iptables with rhel7.2 image with in docker在 docker 中使用 rhel7.2 映像运行 iptables
【发布时间】:2016-05-31 13:53:30
【问题描述】:

在使用 rhel7.2 映像在 docker 内运行 iptables 时,它工作正常。
但是当我尝试运行带有一些规则的 docker 时,它根本没有启动。

这是我的 docker 文件

#######Simplest Docker file which I used for building image and it works from marathon if you dont give cmd or args ########
FROM registry.access.redhat.com/rhel7.2
ADD rhel7.2.repo /etc/yum.repos.d/rhel7.2.repo
RUN yum -y update
RUN yum install iptables -y
CMD ["/usr/sbin/init"]
######### Dockerfile END ####

###to run the docker
sudo docker run -it /bin/bash -c "iptables -t nat -A PREROUTING -p udp -m udp --dport 53 -m statistic --mode nth --every 2 --packet 0 -j DNAT --to-destination 172.31.254.1:10004"

请告诉我怎么了?

【问题讨论】:

    标签: git bash docker iptables


    【解决方案1】:

    如果它在没有提供参数的情况下运行,我怀疑问题是你覆盖了图像的CMD;通过调用/bin/bash -c ...,您将覆盖/usr/sbin/init,因此不会启动iptables。

    您可以启动容器(不带参数),然后使用docker exec -it <containername> bash 在容器中打开一个交互式会话以修改 iptables 设置。

    【讨论】:

      猜你喜欢
      • 2020-01-26
      • 1970-01-01
      • 2020-11-13
      • 2017-04-20
      • 2020-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多