Cleaning Docker environment

Removing a Docker image
docker rmi jenkins

To cleanup any resources - Images, Containers, Volumes and Networks that are dangling - (not associated with a container)
docker system prune

To additionally remove any stopped containers and all unused images (not just dangling images) add -a flag to command.
docker system prune -a

Removing all exited containers
docker rm $(docker ps -a -f status=exited -q)

Remove docker containers according a pattern
docker ps -a | grep "pattern" | awk '{print $3}' | xargs docker rm

To stop all Running docker containers
docker stop $(docker ps -a -q)

To remove all containers from machine.
docker rm $(docker ps -a -q)

Remove all dangling volumes
docker volume prune

To remove all docker images
docker rmi $(docker images -a -q)

Removing docker volumes
docker volume rm volume_name


<< Previous                                                                                                                           Next >>



No comments:

Post a Comment