绑定已安装卷上的Docker每个容器磁盘配额 [英] Docker Per-Container Disk Quota on Bind Mounted Volumes

查看:267
本文介绍了绑定已安装卷上的Docker每个容器磁盘配额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为客户创建一个简单的托管平台.我正在nginx-proxy后面的VPS上通过docker部署所有应用程序.对于wordpress应用程序,我希望能够限制磁盘空间,以便我的客户端不会使用过多的内存并影响其他应用程序.我将所有卷绑定到一个目录,以便可以使用cron轻松备份.

I am trying to create a simple hosting platform for my clients. I am deploying all of my apps via docker on a VPS behind nginx-proxy. For wordpress applications I want to be able to limit disk-space so that my clients do not use too much and affect other applications. I bind mount all volumes to a single directory so that I can back-up easily with cron.

我已将文件系统更改为overlay2并在centos 7上运行.

I've change the file system to overlay2 and am on centos 7.

[root@my-ip ~]# docker info

Server:
  Containers: 12
  Running: 12
  Paused: 0
  Stopped: 0
 Images: 11
 Server Version: 19.03.1
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true

当我使用--storage-opt size = 10G运行wordpress容器时,出现以下错误:

When I run a wordpress container with the --storage-opt size=10G I get the following error:

docker: Error response from daemon: --storage-opt is supported only for overlay over xfs with 'pquota' mount option.

这是我正在使用的绑定安装的示例:

This is an example of the bind mount I am using:

-v/DOCKER_VOLUMES/wordpress/appname/www/html:/var/www/html

如何解决此问题?您能否提供完整的说明列表以启用它?

推荐答案

来自

此(大小)将允许在创建时将容器rootfs大小设置为120G.此选项仅适用于devicemapper,btrfs,overlay2,windowsfilter和zfs图形驱动程序.对于devicemapper,btrfs,windowsfilter和zfs图驱动程序,用户不能传递小于默认BaseFS大小的大小.对于overlay2存储驱动程序,仅当背衬fs为xfs并使用pquota挂载选项挂载时,size选项才可用.在这种情况下,用户可以传递小于背衬fs尺寸的任何尺寸.

This (size) will allow to set the container rootfs size to 120G at creation time. This option is only available for the devicemapper, btrfs, overlay2, windowsfilter and zfs graph drivers. For the devicemapper, btrfs, windowsfilter and zfs graph drivers, user cannot pass a size less than the Default BaseFS Size. For the overlay2 storage driver, the size option is only available if the backing fs is xfs and mounted with the pquota mount option. Under these conditions, user can pass any size less than the backing fs size.

因此,应在系统上启用 pquota

so the pquota should be enabled on your system

您可以像这样编辑文件/etc/default/grub 并重新启动计算机:

you can edit the file /etc/default/grub like so, and restart your machine:

GRUB_CMDLINE_LINUX_DEFAULT="rootflags=uquota,pquota"

,然后尝试使用-storage-opt size = 10G

这篇关于绑定已安装卷上的Docker每个容器磁盘配额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆