模拟docker中的不同网络状况

时间:2015-07-02 19:58:25

标签: docker

使用在Docker container内运行的Selenium + Chrome运行测试,(主机是Ubuntu)

需要为每个容器模拟不同的网络条件,进出带宽,延迟,防火墙。我可以在每个容器上使用https://github.com/tylertreat/Comcast之类的工具,它不会影响其他容器的网络状况吗?

有更好的方法吗?

我看到这个https://github.com/docker/docker/issues/37但不清楚如何使用它。

2 个答案:

答案 0 :(得分:1)

发现这似乎只是起作用,

使用--privileged = true运行docker 在docker镜像中可以使用任何有助于塑造网络流量的程序,为我工作comcast,tc和iptables

每个docker获取自己的网络配置文件,一个容器不会影响其他容器。

另见 https://github.com/tylertreat/comcast/issues/48#issuecomment-326088625

答案 1 :(得分:0)

我正在使用此命令仅影响一个容器的网络条件:

sudo nsenter -t PID -n comcast --latency=2000 --target-port=9200

PID 需要是容器的PID之一

nsenter ... -n 输入容器的网络命名空间