[docker] Batch delete useless images in daily operation and maintenance, delete unstarted containers in batches

docker daily operation and maintenance

1. Query disk usage in Docker

docker system df

insert image description here

2. Delete the Docker image that is not used by the container

[Use with caution] The command cleanup is more clean and thorough, and can delete all Docker images that are not used by containers.

docker system prune -a

3. Delete the unstarted container

By querying all containers, we can find those that are not started, and those that are not needed can be deleted directly

docker ps -a

(1) Delete all non-running containers; running ones cannot be deleted

docker rm $(docker ps -a -q)

(2) Delete the container whose status is Exited according to the status of the container

docker rm $(docker ps -qf status=exited)

Guess you like

Origin blog.csdn.net/wanglei19891210/article/details/130839389