Solve the problem of insufficient docker disk space

Solve the problem of insufficient docker disk space

After the server where Docker is located has been running for a while, it was found that the server disk directory was running out of space. By checking the directories level by level through du -h --max-depth=1 /, it is found that the files in the /var/lib/docker directory are too large. Use the following method to solve this problem.

Transfer data to modify docker default storage location

There are several ways to modify the default storage location of Docker.
It is best to change the default storage location of Docker to another large directory or disk as soon as possible after installing Docker. Avoid risks caused during data migration.

- Stop the docker service

systemctl stop docker

- Create a new docker directory, execute the command df -h, and find a large disk

I created the /data/docker/lib directory under the /data directory

 mkdir -p /data/docker/lib

- Migrate the files under /var/lib/docker directory to /data/docker/lib

Completed docker path after migration: /data/docker/lib/docker

rsync -avz /var/lib/docker/ /data/docker/lib/

- Configure /usr/lib/systemd/system/docker.service

vi /usr/lib/systemd/system/docker.service
[Service]
ExecStart=/usr/bin/dockerd --graph=/data/docker/lib/docker

- Restart Docker

systemctl daemon-reload
systemctl restart docker
systemctl enable docker

- Confirm whether the Docker Root Dir modification has taken effect

[root@iZbp1jcwx7sfb1yrnvpg84Z docker]# docker info
...
Docker Root Dir: /data/docker/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
...

- After the startup is successful, confirm whether the previous image is still there

[root@iZbp1jcwx7sfb1yrnvpg84Z docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
10.80.177.233/policy 2.1.2 64ac4e178cd2 2 hours ago 818 MB
10.80.177.233/crm 2.1.3 d7636fbb7a29 2 hours ago 762 MB

- After confirming that the container is OK, delete the files in the /var/lib/docker/ directory

This is the end of this article about solving the problem of insufficient docker disk space. For more relevant content about insufficient docker disk space, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • About Docker's cleanup of Overlay2's occupied disk space (tested and effective)
  • Solution to Docker disk space cleaning
  • How to clean up the disk space occupied by Docker
  • How to analyze and clean up Docker disk space usage
  • Solution to the problem of Docker taking up all the disk space
  • Solution to the problem of insufficient disk space and inaccessibility caused by Docker container

<<:  Steps and pitfalls of upgrading linux mysql5.5 to mysql5.7

>>:  CSS3 transition to achieve underline example code

Recommend

Detailed explanation of how to enter and exit the Docker container

1 Start the Docker service First you need to know...

Mysql 8.0 installation and password reset issues

Mysql 8.0 installation problems and password rese...

Solve the problem of docker container exiting immediately after starting

Recently I was looking at how Docker allows conta...

Several ways to backup MySql database

mysqldump tool backup Back up the entire database...

Nodejs uses readline to prompt for content input example code

Table of contents Preface 1. bat executes js 2. T...

Native JS to implement breathing carousel

Today I will share with you a breathing carousel ...

How to execute Linux shell commands in Docker

To execute a shell command in Docker, you need to...

What are the new features of Apache Spark 2.4, which will be released in 2018?

This article is from the Apache Spark Meetup held...

Summary of MySQL Architecture Knowledge Points

1. Databases and database instances In the study ...

Build a WebRTC video chat in 5 minutes

In the previous article, I introduced the detaile...

MySQL index failure principle

Table of contents 1. Reasons for index failure 2....

Detailed explanation of Linux server status and performance related commands

Server Status Analysis View Linux server CPU deta...

MySQL Basic Tutorial Part 1 MySQL5.7.18 Installation and Connection Tutorial

Starting from this article, a new series of artic...

Detailed example of mysql trigger usage

MySQL trigger syntax details: A trigger is a spec...