目前给test容器进行动态增加20G空间
15:24:40 # sh dynamic_modify_docker_disk.sh test 20
dynamic container test disk to 20G is success!
root@ip-10-10-27-221:/tmp
15:24:46 # ssh 172.17.0.18
root@172.17.0.18's password:
Last login: Tue Jan 20 15:24:13 2015 from 172.17.42.1
root@1716fe941926:~
15:24:52 # df -hT
Filesystem Type Size Used Avail Use% Mounted on
rootfs rootfs 20G 475M 19G 3% /
/dev/mapper/docker-8:17-37748738-1716fe941926dbd0b247b85d73e83b9465322a5005edc3c6182b59a6ac0939a7
ext4 20G 475M 19G 3% /
shm tmpfs 64M 0 64M 0% /dev/shm
/dev/sdb1 ext4 1.8T 30G 1.7T 2% /.dockerinit
/dev/sda3 ext4 518G 30G 462G 6% /etc/resolv.conf
/dev/sdb1 ext4 1.8T 30G 1.7T 2% /etc/hostname
/dev/sdb1 ext4 1.8T 30G 1.7T 2% /etc/hosts
/dev/sdb1 ext4 1.8T 30G 1.7T 2% /.dockerenv
可以看到已经增加成功
下面在给test增加到50G
15:25:21 # sh dynamic_modify_docker_disk.sh test 50
dynamic container test disk to 50G is success!
root@ip-10-10-27-221:/tmp
15:25:24 # ssh 172.17.0.18
root@172.17.0.18's password:
Last login: Tue Jan 20 15:24:52 2015 from 172.17.42.1
root@1716fe941926:~
15:25:27 # df -hT
Filesystem Type Size Used Avail Use% Mounted on
rootfs rootfs 50G 480M 47G 1% /
/dev/mapper/docker-8:17-37748738-1716fe941926dbd0b247b85d73e83b9465322a5005edc3c6182b59a6ac0939a7
ext4 50G 480M 47G 1% /
shm tmpfs 64M 0 64M 0% /dev/shm
/dev/sdb1 ext4 1.8T 30G 1.7T 2% /.dockerinit
/dev/sda3 ext4 518G 30G 462G 6% /etc/resolv.conf
/dev/sdb1 ext4 1.8T 30G 1.7T 2% /etc/hostname
/dev/sdb1 ext4 1.8T 30G 1.7T 2% /etc/hosts
/dev/sdb1 ext4 1.8T 30G 1.7T 2% /.dockerenv
也可以增加成功
但我要是像缩减到30G
15:25:45 # sh dynamic_modify_docker_disk.sh test 30
I can't shink container test from 50G to 30G!I only modify contanier increase disk!
是无法进行缩减的,仅能进行增加操作。
至于动态增加的原理请参考
FAQ:
centos 7里使用docker的时候默认存储引擎是devicemapper
在进行动态调整docker容器磁盘空间的时候,出现
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Device or resource busy while trying to open /dev/mapper/docker-253:1-1270544-d2d2cef71c86910467c1afdeb79c1a008552f3f9ef9507bb1e04d77f2ad5eac4
Couldn't find valid filesystem superblock.
原因是resize2fs仅能支持ext2、ext3、ext4,不支持xfs
所以建议docker服务器的文件系统格式调整为ext4
在 Docker 中使用 MySQL