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

Summary of Several Methods for Implementing Vertical Centering with CSS

In the front-end layout process, it is relatively...

The use of vue directive v-bind and points to note

Table of contents 1. v-bind: can bind some data t...

The viewport in the meta tag controls the device screen css

Copy code The code is as follows: <meta name=&...

Vue implements the full selection function

This article example shares the specific code of ...

How to modify the initial password of a user in mysql5.7

When users install MySQL database for the first t...

Docker installation and configuration image acceleration implementation

Table of contents Docker version Install Docker E...

Write a publish-subscribe model with JS

Table of contents 1. Scene introduction 2 Code Op...

Detailed explanation of Alibaba Cloud security rule configuration

Two days ago, I took advantage of the Double 11 s...

Element-ui directly clicks on the cell in the table to edit

Table of contents Achieve results Implementation ...

Nginx compiled nginx - add new module

1. View existing modules /usr/local/nginx/sbin/ng...

The difference and usage of Vue2 and Vue3 brother component communication bus

Table of contents vue2.x vue3.x tiny-emitter plug...

js realizes packaging multiple pictures into zip

Table of contents 1. Import files 2. HTML page 3....