By default, Docker is stored in the following locations:
/var/lib/docker
Generally under the root partition we will not give too much. The more images and containers we have, the more generally we have two workarounds.
1. Mount large partitions to/var/lib/docker:
Generally choose to establish logical partition LVM to facilitate later expansion of the collective.
A. Create a new partition and format it
PS: The following operation construction you already have ready-made volume groups, directly can be zoned logical volumes. Or you can create a logical volume yourself, or use a partition that does not apply to logical volumes
Lvcreate-l 300G lv_docker vg_home
mkfs.ext4/dev/vg_home/lv__docker
B. Mounting a new partition to a temporary mount point
Mkdir/mnt/docker
mount/dev/vg_home/lv_docker/mnt/docker/
C. After you stop the Docker, copy the/var/lib/docker data to the temporary mount point
Service Docker stop
cp-r/var/lib/docker/*/mtn/docker
D. Modify/var/lib/docker to//var/lib/docker.bak and create/var/lib/docker
Mv/var/lib/docker{,.bak}
Mkdir/var/lib/docker
E. Mount the new partition to the/var/lib/docker, and set the boot auto mount.
Mount/dev/vg_home/lv_docker/var/lib/docker
vim/etc/fstab
---
/dev/vg_home/lv_docker/docker_data ext4 defaults 0 0
----
F. Detect if Docker is available and data is complete
Docker images
G. Uninstall the temporary mount point after confirming the error, remove the/var/lib/docker.bak
Umount/mnt/docker
Rm-rf/var/lib/docker.bak
2, modify the image and container storage path:
It is simple to specify that the parameters for mirroring and container storage paths are--graph=/var/lib/docker.
We just need to modify the configuration file to specify the startup parameters.
Vim/etc/sysconfig/docker
------------
other_args= "--graph=/docker"
------------
Stop Docker.
Service Docker stop
Back up data to a new container storage directory
Cp-r/var/lib/docker/docker/
Modify Source Store Directory name
Mv/etc/lib/docker{,.bak}
Start Docker
Service Docker start
Test
Docker images