Increase Docker container storage size on CentOS

夙愿已清 提交于 2021-01-29 18:33:24

问题


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:


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:


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 .



来源:https://stackoverflow.com/questions/59610957/increase-docker-container-storage-size-on-centos

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!