Docker in/var
A large amount of space occupation may occur in the directory, mainly due to the accumulation of mirrors, containers, data volumes and temporary files. To clean up these resources, you can use the following methods:
Note: These actions will delete your Docker resources, so make sure you have backed up important data before executing.
1. Delete unused Docker images
Run the following command to delete all unused images:
docker system prune -a --volumes
This will delete all unused images, containers, networks, and data volumes.
2. Delete single useless images, containers, networks, and data volumes
- Delete the mirror:
docker rmi <IMAGE_ID>
- Delete the container:
docker rm <CONTAINER_ID>
- Delete the network:
docker network rm <NETWORK_ID>
- Delete data volumes:
docker volume rm <VOLUME_ID>
To get<IMAGE_ID>
、<CONTAINER_ID>
、<NETWORK_ID>
and<VOLUME_ID>
, you can use the following command:
- List the images:
docker images
- List containers:
docker ps -a
- List the network:
docker network ls
- List the data volumes:
docker volume ls
3. Delete the hanging mirror
A hanging mirror is a mirror that is not associated with any container. You can delete the dangling image by running the following command:
docker image prune
4. Delete the stopped container
Run the following command to delete all stopped containers:
docker container prune
5. Delete unused data volumes
Run the following command to delete all unused data volumes:
docker volume prune
6. Delete unused networks
Run the following command to delete all unused networks:
docker network prune
7. Manual cleaning/var
Docker temporary files in the directory
You can also delete it manually/var/lib/docker/tmp
Temporary files in the directory. First, make sure that the Docker service is stopped, and then execute the following command:
sudo systemctl stop docker sudo rm -rf /var/lib/docker/tmp/* sudo systemctl start docker
After performing the above operation, Docker is/var
The space usage in the directory should be greatly reduced.
This is the article about how to clean up the large amount of space occupied by docker in the var directory. For more related contents of docker in the var directory, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!