Disk quota for Docker Containers

We run database like postgres,mysql within Docker Containers. What is the best way to assign quotas to the volumes for the same.

  1. Via the host using setquota and mapping to a userid
  2. Using a volume driver which can talk to Block storages like Cinder or AWS Block Storage.

I’m not sure if this will help your use case, but docker run does have some knobs you can turn (flags) to control access to devices and block IO:

--blkio-weight                  Block IO (relative weight), between 10 and 1000
--blkio-weight-device=[]        Block IO weight (relative device weight)
....
--device=[]                     Add a host device to the container
--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

We are trying the uid concept for limiting disk quotas. Since Swarm is the scheduler we use, the way I am trying to tackle is that having a mapping file of uid at swarm server level, and use constraints at the docker daemon level to let swarm choose containers of a specifc UID end up going to the node and thereby quota gets applied.Thoughts/Suggestions?

I don’t understand. Could you explain more about what you are trying to accomplish, or point me to a link which explains this concept?

Hi Nathan,
We assign user ids to the containers. And each userid(uid) has a quota of disk on host.
As Swarm level we maintain a mapping of userids to the name of the docker image we want to run on a particular host with quota applied.
Then we use constraints at the docker daemon level (using node=the userids),so that swarm spins the containers for the specific user id on the host on which the quotas are defined for that user id.
Regards
Shashank