I can apply disk size quota with "--storage-opt size=1536M" argument when working under devicemapper. For example:
docker run -dt --name testing --storage-opt size=1536M ubuntu
the problem is, how can I do this by using docker-compose, via a compose *.yml file.
thanks.
Use devicemapper as default storage driver for Docker and set basesize for every container.
To use devicemapper as the default:
1) apt-get install lvm2 thin-provisioning-tools
2) change /etc/default/docker as this:
--storage-driver devicemapper --storage-opt dm.basesize=3G
3) do these one by one:
systemctl stop docker
systemctl daemon-reload
rm -rf /var/lib/docker
systemctl start docker
4) now your containers have only 3GB space. In addition, you can define vol. space when using RUN command with devicemapper (size must be equal or bigger than basesize). For eg:
docker run --storage-opt size=1536M ubuntu
The minimum allowed value is 4m . Because kernel memory cannot be swapped out, a container which is starved of kernel memory may block host machine resources, which can have side effects on the host machine and on other containers.
Limit Docker Container CPU Usage You can also use the --cpu-shares option to give the container a greater or lesser proportion of CPU cycles. By default, this is set to 1024. To find more options for limiting container CPU usage, please refer to Docker's official documentation.
While docker-compose scale is useful for small environments like a single Docker host running in production. It is also very useful for developers running Docker on their workstation. It can help them test how the app will scale in production, and under different circumstances.
Try this:
storage_opt:
size: '1G'
as in https://docs.docker.com/compose/compose-file/compose-file-v2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With