Home > Operation and Maintenance > Docker > What should I do if there is not enough space in docker?

What should I do if there is not enough space in docker?

coldplay.xixi
Release: 2020-06-13 12:51:54
Original
2771 people have browsed it

What should I do if there is not enough space in docker?

What should I do if there is not enough docker space?

Methods to solve insufficient docker space:

1. Check the space size of the docker image storage directory

du -hs /var/lib/docker/
Copy after login

2. Stop the docker service.

systemctl stop docker
Copy after login

3. Check the disk space with large capacity and create a new docker directory on it.

df -h
mkdir -p /data/docker/lib
Copy after login

4. Migrate the files in the /var/lib/docker directory to the newly created directory /data/docker/lib

rsync -avz /var/lib/docker /data/docker/lib/
Copy after login

5. Edit /etc/docker/daemon.json and add The following parameters

{
  "graph": "/data/docker/lib/docker"
}
Copy after login

6. Reload docker and restart the docker service.

systemctl daemon-reload && systemctl restart docker
Copy after login

7. Check whether docker has been changed to the new directory /data/docker/lib/docker

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

8. Delete the old docker directory

rm -rf /var/lib/docker
Copy after login

Common docker cleaning methods

docker system df is similar to the df command on Linux, used to check Docker's disk usage:

docker system prune can be used to clean up the disk, delete closed containers, useless data volumes and Network, and dangling mirrors (ie, untagged mirrors).

docker system prune -a cleans more thoroughly and can delete all containers that do not use Docker images. Note that these two commands will delete the containers you have temporarily closed and the Docker images that are not used yet... so be sure to think clearly before using them.

Recommended tutorial: "docker video tutorial"

The above is the detailed content of What should I do if there is not enough space in docker?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template