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.

  • Mounting nfs shares inside docker container
  • Creating an environmental variable within Docker container when starting up
  • How to deploy using capistrano without current release symlink?
  • docker-compose build and http_proxy
  • Docker: how to work with local files?
  • How to add volume to Docker but exclude files
  • My question, how would I add a mount option to a docker container?

  • Docker config : Celery + RabbitMQ
  • docker-compose volume on node_modules but is empty
  • Docker engine fillingup storage
  • start multiple docker containers with a single command line shell script (without docker-compose)
  • How to run HDFS cluster without DNS
  • Salt: 'dockerng' __virtual__ returned False
  • 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
    

    Source

    https://goldmann.pl/blog/2014/09/11/resource-management-in-docker/#_limiting_disk_space

    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.

    Source https://github.com/docker/docker/issues/471#issuecomment-22373948

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.