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

How to invert the implementation of a Bezier curve in CSS

First, let’s take a look at a CSS carousel animat...

MySQL paging performance exploration

Several common paging methods: 1. Escalator metho...

Detailed explanation of MySQL Group by optimization

Table of contents Standard execution process opti...

A brief discussion on Linux virtual memory

Table of contents origin Virtual Memory Paging an...

Steps to enable TLS in Docker for secure configuration

Preface I had previously enabled Docker's 237...

Detailed explanation of MySQL joint query optimization mechanism

Table of contents MySQL federated query execution...

Pure CSS implementation of radio and checkbox effect example

radio-and-checkbox Pure CSS to achieve radio and ...

Tutorial on building nextcloud personal network disk with Docker

Table of contents 1. Introduction 2. Deployment E...

Implementation of communication between Vue and Flask

Install axios and implement communication Here we...

How to quickly paginate MySQL data volumes of tens of millions

Preface In backend development, in order to preve...

Detailed examples of float usage in HTML/CSS

1. Basic usage examples of float 1. Let's fir...

JS realizes special effects of web page navigation bar

This article shares with you a practical web navi...

Things You Don’t Know About the CSS ::before and ::after Pseudo-Elements

CSS has two pseudo-classes that are not commonly ...