在 CentOS 上增加 Docker 容器存储大小

Increase Docker container storage size on CentOS

我想增加 Docker 容器的磁盘 space。这是 docker info.

的输出
Containers: 3
Running: 3
Paused: 0
Stopped: 0
Images: 4
Server Version: 19.03.5
Storage Driver: overlay2
Backing Filesystem: extfs 
Supports d_type: true
Native Overlay Diff: true

我读到磁盘 space 默认为 10GB,据说 overlay2 取消了此限制。这对我来说似乎不是这样。

docker run -d --name jd2 --restart always  -v $HOME/docker/volumes/jd2:/opt/JDownloader/cfg -v $HOME/downloads:/opt/JDownloader/Downloads plusminus/jdownloader2-headless

请按照以下步骤增加 docker 容器的默认大小 -

#Modify the docker config in /etc/sysconfig/docker-storage to add the line:
DOCKER_STORAGE_OPTIONS= - -storage-opt dm.basesize=20G

# Stop the docker service
service docker stop

rm /var/lib/docker 
#NOTE THIS DELETES ALL IMAGES , SO MAKE A BACKUP

# Restart the docker service 
service docker start

docker load < [each_save_in_backup.tar]
docker run -i -t [imagename] /bin/bash

In the bash prompt of the docker container “df -k” should show 20GB / file system 
size now.

如果这没有帮助,请告诉我。

I have read that the disk space is 10GB by default, supposedly this limit is dropped with overlay2. This does not seem to be the case for me.

这不准确。

Docker 的早期版本在 CentOS 上使用 devicemapper 存储驱动程序,它为每个容器创建一个新的虚拟块设备。在这种情况下,每个容器的默认大小为 10GB,可以通过 dm.basesize 存储选项进行控制。

由于内核更新和额外的开发工作,CentOS 和大多数其他发行版上的默认存储驱动程序是 overlay2 存储驱动程序。这不再依赖于每个容器的块设备,而是使用 overlayfs。这样做的实际影响之一是不再有每个容器的存储限制:所有容器都可以访问 /var/lib/docker 下的所有 space。不再有任何类型的每个容器 10GB 限制。

有关 the overlay2 storage driver 的详细信息,请参阅文档。

如果在 /var/lib/docker 中 space 中有 运行,您可以像添加任何其他文件系统一样添加 space。