英文:
Increase Docker container storage size on CentOS
问题
我想增加 Docker 容器的磁盘空间。以下是来自 docker info 的输出。
容器数:3
正在运行:3
已暂停:0
已停止:0
镜像数:4
服务器版本:19.03.5
存储驱动程序:overlay2
后端文件系统:extfs
支持 d_type:true
本地叠加差异:true
我已经了解到磁盘空间默认为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
英文:
I want to increase the disk space of a Docker container. Here is the output from 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
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 run -d --name jd2 --restart always -v $HOME/docker/volumes/jd2:/opt/JDownloader/cfg -v $HOME/downloads:/opt/JDownloader/Downloads plusminus/jdownloader2-headless
答案1
得分: 4
以下是翻译好的部分:
我已经阅读到默认情况下磁盘空间为10GB,据说这个限制在overlay2下被取消了。对我来说似乎并非如此。
这是不准确的。
早期版本的Docker在CentOS上使用了devicemapper
存储驱动程序,为每个容器创建了一个新的虚拟块设备。在这种情况下,每个容器的默认大小为10GB,并且可以通过dm.basesize
存储选项进行控制。
由于内核更新和额外的开发工作,CentOS和大多数其他发行版上的默认存储驱动程序现在是overlay2
存储驱动程序。这不再依赖于每个容器的块设备,而是利用overlayfs。其中一个实际影响是不再存在每个容器的存储限制:所有容器都可以访问/var/lib/docker
下的所有空间。不再存在每个容器的10GB限制。
有关overlay2存储驱动程序的更多信息,请参阅文档。
如果您在/var/lib/docker
中的空间不足,您可以像为任何其他文件系统添加空间一样进行操作。
英文:
> 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.
That is not accurate.
Earlier releases of Docker used the devicemapper
storage driver on CentOS, which creates a new virtual block device for each container. In this case, the default per-container size was 10GB, and could be controlled by the dm.basesize
storage option.
Thanks to kernel updates and additional development work, the default storage driver on CentOS and most other distributions is the overlay2
storage driver. This no longer relies on a per-container block device, and instead makes use of overlayfs. One of the practical impacts of this is that there is no longer a per-container storage limit: all containers have access to all the space under /var/lib/docker
. There is no longer any sort of per-container 10GB limit.
See the documentation for more information about the overlay2 storage driver.
If you are running out of space in /var/lib/docker
, you can add space as you would for any other filesystem.
答案2
得分: 0
请按照以下步骤来增加 Docker 容器的默认大小 -
在 /etc/sysconfig/docker-storage 中修改 Docker 配置以添加以下行:
DOCKER_STORAGE_OPTIONS=--storage-opt dm.basesize=20G
停止 Docker 服务
service docker stop
rm /var/lib/docker
注意:这会删除所有镜像,所以请备份
重新启动 Docker 服务
service docker start
docker load < [each_save_in_backup.tar]
docker run -i -t [imagename] /bin/bash
在 Docker 容器的 Bash 提示符下执行 "df -k" 命令应该显示 20GB 的文件系统大小。
如果这不起作用,请告诉我。
英文:
Please follow the steps below to increase the default size of a docker container -
#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.
Let me know if this doesnt help .
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论