I want to apply NetEm delay on the egress traffic of a docker container. Usually, I run:
# /sbin/tc qdisc add dev $INTERFACE root netem delay ${DELAY}ms
The issue is that I have no idea about the interface to which the container is connected to.
For example, I am running the following container:
docker run --rm -it alpine /bin/sh
and then I ping 8.8.8.8:
/ # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=44 time=39.783 ms
64 bytes from 8.8.8.8: seq=1 ttl=44 time=39.694 ms
What I want to do is adding the NetEm rule from my host machine and see changes to the ping time.
If I run ifconfig
, I see that several virtual ethernet interfaces are present (since other containers are running), but I don't know which one is connected to the container I am interested in:
# ifconfig
veth09fa1c5 Link encap:Ethernet HWaddr 96:73:c9:15:93:b8
inet6 addr: fe80::9473:c9ff:fe15:93b8/64 Scope:Link
.....
vethf05ef93 Link encap:Ethernet HWaddr ca:ea:97:ef:cd:9d
inet6 addr: fe80::c8ea:97ff:feef:cd9d/64 Scope:Link
.....
I believe that I have to apply the NetEm rule to one of these interfaces. Is that correct?