Site icon Voina Blog (a tech warrior's blog)

#Docker images cleanup

Advertisements

CASE 1: If you use multi-stage docker builds you will end up with lots of un-tagged images.

The proper way to clean the intermediary leftover images is:

docker rmi $(docker images -f "dangling=true" -q)

CASE 2: If you want to clean up all the old images for which you no longer have any instantiated container

docker image purge

CASE 3: If you want to delete all stopped containers and their images

docker container purge
docker image purge

Note: Be very careful the above will remove ALL stopped containers, so make sure that if you want to keep a container alive it has to be running when commands are issued.

Exit mobile version