官网找到,有个属性,可以用来配置容器大小
- 在创建容器的时候使用参数
--storage-opt size=10G
来设置改容器的 rootfs 大小。
官方文档如下:
Set storage driver options per container
$ docker run -it --storage-opt size=120G fedora /bin/bash
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.
谷歌翻译:
设置每个容器的存储驱动程序选项🔗
$ docker run -it --storage-opt size=120G fedora /bin/bash
此(大小)将允许在创建时将容器rootfs大小设置为120G。此选项仅适用于devicemapper
,btrfs
,overlay2
, windowsfilter
和zfs
图形驱动程序。对于devicemapper
,btrfs
,windowsfilter
和zfs
图形驱动程序,用户无法设置比默认BaseFS 小的size。对于overlay2
存储驱动程序,只有在支持fs xfs
并通过pquota
mount选项进行安装的情况下,size选项才可用。
在满足前面overlay2
条件下,用户可以设置任意比 backing fs size 小的值。
解释一下:
默认情况下,每个 Docker 容器都有 10G 的存储空间,当超出该大小时,容器就会出现问题。那么修改容器大小,有两个方向,一个是比10G 大【即驱动程序为devicemapper
,btrfs
,windowsfilter
和zfs
】,一个是比10G小【即驱动程序为overlay2,且
只有在支持fs xfs
并通过pquota
mount选项进行安装的情况下】。当然,默认的存储空间,也是可以修改的【文末介绍】。
查看docker的 驱动程序类型:docker info