Docker – Editing Mount Options
I am adding a disk quota to my Ubuntu docker container. To add quota support, I need to edit the mount options and add
usrquota as explained here: https://www.digitalocean.com/community/tutorials/how-to-enable-user-and-group-quotas
Usually you would edit /etc/fstab and add the mount option.
My question, how would I add a mount option to a docker container?
One Solution collect form web for “Docker – Editing Mount Options”
You don’t really mount container’s disks anywhere. There is a feature request asking for setting quotas in Docker containers (https://github.com/docker/docker/issues/3804) so at the moment there is no easy way.
However, apparently there are a couple of workarounds.
Use Device Mapper as a limit
Docker containers have a maximum of 10GB of disk space, per container (that is the Device Mapper storage driver by default).
So your best option is to change the default value for new containers, but then, it is my understanding you would need to rebuild the containers.
So, if you want to enforce 5 gigabytes, you would write
docker -d --storage-opt dm.basesize=5G
User inside/quota outside
The trick is create a specific user account in each container, and assign a userid for that account (and obviously run the command with that account).
On the host, we would use
setquota to limit this userid.