How do you limit volume storage?

Hi,

I actually use virtualhost for websites (wordpress/nextcloud/pydio/…).

Actually I have a small hosted server with RAID1 storage and ext4 filesystem.

I want to use docker to be able to switch easily nginx/php version, have a simpler deployment,…

I test it and it works great.

However, with virtualhost I use the package “quota” to limit space disk storage. This was important for me because websites like nextcloud/pydio can take rapidly a lot of space.

I notice docker don’t have by default a size option for volume or need a specific filesystem or dedicated disk.

Since I can’t add a disk or set another filesystem, how can I reproduce “quota” for container ?

Is it possible to use something like virtual filesystem (something like qcow2) to store volume container and limit size ?

How should I do and if you already encoutered this issue how do you handle it ?

It is a good approch to do something like this ?
To have a volume limited to 5Go

dd if=/dev/zero of=/opt/docker_volume/container1.img bs=1M count=5120
mkfs.ext4 /opt/docker_volume/container1.img
sudo mount -t ext4 -o loop /opt/docker_volume/container1.img  /mnt/docker/container1/
docker run -v /mnt/docker/container1/:/mydata mycontainer

You might want to take a look at volume plugins.
Some of them provide quota capabiiltes, e,g, Flocker (see: https://github.com/ClusterHQ/flocker)

I only see flocker (for my requirements). But it is abandonned.

Flocker was just an example for a volume pugin.

I have google the terms “docker volume plugins” for you. The first hit is:

Check the list and find a suiting volume plugin.