How to solve the problem that Docker occupies the full mark area under Linux system
- 2020-06-19 12:04:34
- OfStack
I encountered a problem today. When accessing the database, I found that I could not access it and the storage space was not enough. Then I entered the command:
df -h
found
/dev/vda1
The system disk is full. Not full-time operation and maintenance, so, began to solve the problem baidu. Here is the solution path:
The first is to find the large file storage location by command
du -sh /*
When I found some directories, I found that some directories were very large, such as /var.
Then confirm the partition,
df /var
, found the partition of this directory is
/dev/vda1
So I go into this directory and I start deleting things. I started deleting a lot of logs, but it didn't work, so I used the command again:
du -sh *
;
in
/var
Found in directory
/lib/docker
The folder footprint is the largest, so you know what the problem is, docker's image and container are placed in the directory by default
/var/lib/docker
Below, occupy 6.6G;
The next problem is understood, which is to solve the problem that docker takes up too much space. Therefore, the first idea of 1 is to remove the unnecessary containers and mirrors, but unfortunately, the space is not reduced. So, I started the second idea, which was to export the image and container I needed, but even more tragically, there was not enough space to export...
Because mirror image is done for a long time, so do not want to give up easily. After thinking for a long time, I finally came up with an idea. Remove the /var/lib/docker folder, and then reset the docker data store location.
Steps are as follows (CentOS) :
/etc/init.d/docker stop # Shut down docker
mv /var/lib/docker /home/docker # Out of docker The data ( home The directory is not mounted on the system disk. At this point, the system disk problem is resolved
Then set docker to be the data storage location, edit /etc/sysconfig/docker file, add -ES41en parameter Settings, as follows:
other_args="-g /home/docker"
Start the docker
/etc/init.d/docker start
So that's it.