Home  >  Article  >  Operation and Maintenance  >  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
coldplay.xixiOriginal
2020-06-12 13:19:152594browse

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/

2. Stop the docker service.

systemctl stop docker

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

df -h
mkdir -p /data/docker/lib

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/

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

{
  "graph": "/data/docker/lib/docker"
}

6. Reload docker and restart the docker service.

systemctl daemon-reload && systemctl restart docker

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/
...

8. Delete the old docker directory

rm -rf /var/lib/docker

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!

Statement:
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