4

I would like to introduce network variability into docker containers. Specifically, I would like to be able to run commands such as:

sudo tc qdisc add dev vethecb732a root netem delay 500ms 400ms distribution normal

and other related network configuration commands within the docker-machine environment.

Docker seems to create and name a network adapter for each container which is running within docker-machine. However, I am not sure how to associate the information I have available for the container to the actual randomly generated network adapter name, in order to execute commands such as the above correctly.

When I get the info from ip addr within docker-machine for this container:

22: veth5009782@if21: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether 4a:f8:d0:05:b6:90 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::48f8:d0ff:fe05:b690/64 scope link 
       valid_lft forever preferred_lft forever

And these are the network settings for the container:

    "NetworkSettings": {
        "Bridge": "",
        "SandboxID": "3092a7a4d0c09b7461ec2683653f315ed872710e9f74656b6292ada8d2c45931",
        "HairpinMode": false,
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "Ports": {},
        "SandboxKey": "/var/run/docker/netns/3092a7a4d0c0",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null,
        "EndpointID": "9fa9f74c3e412264055b3976acd0c740997390625a45e8f6c4fe862acd9e8db8",
        "Gateway": "172.17.0.1",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "IPAddress": "172.17.0.2",
        "IPPrefixLen": 16,
        "IPv6Gateway": "",
        "MacAddress": "02:42:ac:11:00:02",
        "Networks": {
            "bridge": {
                "IPAMConfig": null,
                "Links": null,
                "Aliases": null,
                "NetworkID": "10bb8d5490be0addeacc073534df9517e7fd81f5c607b99cf859a6f4218e9251",
                "EndpointID": "9fa9f74c3e412264055b3976acd0c740997390625a45e8f6c4fe862acd9e8db8",
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.2",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "MacAddress": "02:42:ac:11:00:02"
            }
        }
    }

I have verified that my tc qdisc configuration works, when executed manually. I am just not sure how to associate the right device with the docker container and allow programmatic tc rules.

As best I can see, there is nothing straightforward to associate the container to the docker-machine adapter.

I am running a basic ubuntu-trusty image for tests.

One option is to build a list of network names to containers as I start them (assuming that the highest index is the newest container) and then storing this and using it, but it feels fairly brittle and will be destroyed if multiple processes are using the same docker-machine and starting containers (or using docker-compose).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.