Created
August 5, 2015 19:01
-
-
Save dnephin/73dc7476e3ca15bffbca to your computer and use it in GitHub Desktop.
docker_tc - using tc with a docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# | |
# | |
set -eu | |
DOCKER_RUN_PATH=/var/run/docker/execdriver/native/ | |
STATE_JSON=state.json | |
container=$1 | |
id="$(docker inspect -f '{{ .Id }}' $container)" | |
state_file="$DOCKER_RUN_PATH/$container/$STATE_JSON" | |
veth="$(cat $state_file | jq -r '.config.networks[].host_interface_name' | grep veth)" | |
# Example just with 30% loss | |
tc qdisc replace dev $veth root netem loss 40% | |
# Example drop | |
tc qdisc replace dev $veth root netem delay 75ms 100ms distribution normal | |
# Example restore | |
tc qdisc del dev $veth root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment