0

I have changed storage plugin to DeviceMapper. Docker info gives following output.

Server Version: 1.9.0
Storage Driver: devicemapper
 Pool Name: docker-253:1-16-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 107.4 GB
 Backing Filesystem: extfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 1.821 GB
 Data Space Total: 268.4 GB
 Data Space Available: 11.66 GB
 Metadata Space Used: 2.101 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.145 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.90 (2014-09-01)
Execution Driver: native-0.2

First of all, I don't know, how to set quota per container. Should I use maybe flgas in docker run commands?

Jørgen R
  • 10,568
  • 7
  • 42
  • 59

1 Answers1

0

With devicemapper as storage plugin, you can not set disk size per container. It would be of a fixed size for each container. And as per the output of docker info it suggests that the fixed size would be of around 100GB. However, you can have one of the following 2 options depending on your requirement.

a.) You can change this fixed size from 100GB to some other value like 20GB but in that case as well all the containers would be having fixed disk size as 20GB. If you want go ahead with this option, you can follow this:

  1. Stop docker service, sudo service docker stop

  2. Remove the existing docker directory (which in your case is default one i.e. /var/lib/docker)-- NOTE this will delete all your existing docker images and containers.

  3. Start docker daemon with option docker daemon -s devicemapper --storage-opt dm.basesize=20G

  4. Or in place of step 3, add option DOCKER_OPTS='-g /var/lib/docker -s devicemapper --storage-opt dm.basesize=5G'in the file /etc/default/docker and restart docker service

    sudo service docker start

Now, whatever containers you will spawn, would be having disk size as 20GB.

b.) As a second option, you can increase disk size of your existing containers from whatever base disk size you have set. (which by default is 100GB and if you follow first option, then 20GB). To do this, here is a very useful article you can follow. This may help in letting you set different disk size for different containers.

Hope this answer is useful for your requirement, thanks.

Community
  • 1
  • 1
ginni
  • 1
  • 3
  • I have talked earlier about this with Jérôme Petazzoni. He said, this solution is deprecated, so isn't working. –  Jan 24 '16 at 22:38
  • I have used the solution with docker 1.9 and its working. even I have modified docker source code for our requirement using this solution, i.e. while creating container only I send the disk size for container and change its disk size and resize FS and it works there as well. Even I see [here](https://github.com/shishir-a412ed/docker/commit/21ebfd5d26d63ffca592cbca30105358f7f00e2d) some work going to implement similar approach in future docker release. you might follow this, if it helps. – ginni Jan 25 '16 at 08:46
  • Do you have maybe tutorial or article about this solution? It sounds interesting. Disc quota limiting is a very interesting part of Docker nowadays! –  Jan 25 '16 at 08:55