Skip to content

Instantly share code, notes, and snippets.

@moxiegirl
Created November 9, 2015 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moxiegirl/a7bc16b00dbdb0c45bac to your computer and use it in GitHub Desktop.
Save moxiegirl/a7bc16b00dbdb0c45bac to your computer and use it in GitHub Desktop.

Block IO bandwidth (Blkio) constraint

By default, all containers get the same proportion of block IO bandwidth (blkio). This proportion is 500. To modify this proportion, change the container's blkio weight relative to the weighting of all other running containers using the --blkio-weight flag.

Note: The blkio weight setting is only available for direct IO. Buffered IO is not currently supported.

The --blkio-weight flag takes a weight between 10 to 1000. For example, the commands below create two containers with different blkio weight:

    $ docker run -ti --name c1 --blkio-weight 300 ubuntu:14.04 /bin/bash
    $ docker run -ti --name c2 --blkio-weight 600 ubuntu:14.04 /bin/bash

If you do block IO in the two containers at the same time, for example:

    $ time dd if=/mnt/zerofile of=test.out bs=1M count=1024 oflag=direct

You'll find that the proportion of time is the same as the proportion of blkio weights of the two containers.

The --blkio-weight-device="DEVICE_NAME:WEIGHT" flag sets a specific device weight. The DEVICE_NAME:WEIGHT is a string containing a colon-separated device name and weight. For example, to set /dev/sda device weight to 200:

$ docker run -it \
    --blkio-weight-device "/dev/sda:200" \
    ubuntu

If you specify both the --blkio-weight and --blkio-weight-device, Docker uses the --blkio-weight as the default weight and uses --blkio-weight-device to override with a different weight on a specific device. The following example uses a default weight of 300 and overrides this default on /dev/sda setting with a weight of 200:

$ docker run -it \
    --blkio-weight 300 \
    --blkio-weight-device "/dev/sda:200" \
    ubuntu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment