Temporarily, I use the -v
param like /rootfs/shared_dir:/docker/docker_file
.
My container creates some data file in the folder and I want to share the folder with my system.
Also I want to limit the IO speed in the docker container. How can I do this?
After version 1.10 docker added new features to manipulate IO speed in the container.
~$ docker help run | grep -E 'bps|IO'
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
--blkio-weight Block IO (relative weight), between 10 and 1000
--blkio-weight-device=[] Block IO weight (relative device weight)
--device-read-bps=[] Limit read rate (bytes per second) from a device
--device-read-iops=[] Limit read rate (IO per second) from a device
--device-write-bps=[] Limit write rate (bytes per second) to a device
--device-write-iops=[] Limit write rate (IO per second) to a device
for example if you want to limit write speed to 50 MB/s
$ docker run -it --rm --device-write-bps /dev/sda:50mb ubuntu /bin/bash
root@e88db9cb1263:/# time dd if=/dev/zero of=test.out bs=1M count=1024 oflag=direct
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 20.4334 s, 52.5 MB/s
real 0m20.437s
user 0m0.016s
sys 0m0.472s
without limit my speed is 291 MB/s
~$ docker run -it ubuntu bash
root@2911226bd75e:/# time dd if=/dev/zero of=test.out bs=1M count=1024 oflag=direct
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 3.69373 s, 291 MB/s
real 0m3.696s
user 0m0.004s
sys 0m0.496s
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With