docker默认数据都保存在/var/lib/docker目录下,默认情况下根分区空间都不大,在网上找到个方案:
service docker stop
cp -prf /var/lib/docker /mnt/data/
umount /var/lib/docker/devicemapper
umount /var/lib/docker/plugins
rm -rf /var/lib/docker
ln -s /mnt/data/docker /var/lib
(或用fstab和mount)
vi /etc/fstab
追加以下内容:/data/docker /var/lib/docker none bind 0 0
mount -a
thin_check /mnt/data/docker/devicemapper/devicemapper/metadata
thin_check --clear-needs-check-flag /mnt/data/docker/devicemapper/devicemapper/metadata
service docker start
后续步骤:
- 删除没启动的images:
docker rmi $(docker images -q) - 删除没启动的containers
docker rm $(docker ps -a -q)