Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate different network condition in docker

Tags:

docker

Run test using Selenium + Chrome that run inside a Docker container, (Host is Ubuntu)

Need to simulate different network condition for each container, in and out bandwidth, latency, firewalls. can I use tool like https://github.com/tylertreat/Comcast on each container and it will not effect the networking condition of other containers?

Is there a better way to do that?

I see this https://github.com/docker/docker/issues/37 but not clear how to use it.

like image 609
user1929819 Avatar asked Jul 02 '15 19:07

user1929819


2 Answers

I'm using this command to affect only the network conditions of one container:

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

PID needs to be one of the PIDs of the container

nsenter ... -n enter in the network namespace of the container

like image 90
adrianlzt Avatar answered Sep 28 '22 21:09

adrianlzt


Found this seem to be just working,

docker run with --privileged=true in the docker image can use any program that work to shape the network traffic, worked for me comcast, tc and iptables

each docker get his own network profile and one container does not effect other containers.

see also https://github.com/tylertreat/comcast/issues/48#issuecomment-326088625

like image 32
user1929819 Avatar answered Sep 28 '22 21:09

user1929819