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