S
S
Shurik2020-06-03 15:48:35
Docker
Shurik, 2020-06-03 15:48:35

How to remove unnecessary containers and images in docker?

Good afternoon. Connoisseurs, please tell me how to delete already unused containers and images in docker?
Let's say I've finished a project and want to delete everything related to it.
What I do:
- stop project containers docker-compose stop
- delete volumes docker-compose rm -v
but as far as I understand downloaded images remain. The docker images command lists all images. But how to understand which ones to delete among others? That is, roughly by name, I imagine, but there are many similar ones and I'm afraid to remove them from other projects. Perhaps there is some kind of docker-comose command to remove the images of the project?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ighor July, 2020-06-03
@IGHOR

And docker won't let you delete an image used in other containers without the --force option.
So you can just write docker image prune

V
Vitaly Karasik, 2020-06-03
@vitaly_il1

https://vsupalov.com/cleaning-up-after-docker/ :
docker-compose down -v --rmi all --remove-orphans

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question