The root disk was full due to a large docker data file

  • 2020-06-12 11:34:30
  • OfStack

Background:

Recently the docker host used online found that the root directory capacity is nearly full, a search, found that docker's data file is too large. As we know that docker data is stored under /var/lib/docker by default, we can use the -g --graph="" parameter at startup to change the data directory to another place with large capacity. However, in the case of docker in use, modifying the directory path directly would result in both the image and the container being lost, so modifying parameters is a good method for initializing docker.

To want to solve the root partition full capacity, and don't want to change the data storage paths of me, I don't want to change any docker parameters and data, so I try it on your own virtual machine machine environment the data migration to the larger disk capacity, with a link to the way the data link to the original position, ensure the environment does not change as much as possible.

Operation:

1: Close the docker container and docker process:


# /etc/init.d/docker stop

2: Migration data: (suppose I want to migrate to /mnt/docker)


# mv /var/lib/docker /mnt/

3: Make directory links


# ln -s /mnt/docker /var/lib/docker
# cd /var/lib
# ll
lrwxrwxrwx 1 root  root   11 Apr 13 10:52 docker -> /mnt/docker

4: Start docker and container:


# /etc/init.d/docker start

Related articles: