1

I have several docker images in my ubuntu pc that are taking a lot of space. I want to delete them except the one I am currently using.

However, other than the images I can clearly identify (by their names and tags) there are other images that I suppose were created in the intermediate process of creating the images. They are also listed in docker images

Since I am still using one of the images (I run it from time to time) I am a bit afraid of erasing some unidentified image that might have some relation

How do I delete docker images that I am not using safely?(including intermediate ones)

(just in case I know that docker rmi is used to delete images. That is not the matter of this question)

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
  • 4
    `docker image prune` maybe ? See the doc : https://docs.docker.com/config/pruning/ – Flo Apr 20 '22 at 08:22
  • There shouldn't be any risk of deleting an image that's not attached to a running container, since you should be able to `docker pull` it from a registry or `docker build` it from source. `docker run` will automatically pull the image if it's not present locally. – David Maze Apr 20 '22 at 10:22
  • @DavidMaze Thanks. One question, what happens if the image is running at the moment and I delete one of the associated images? I can understand there will be a `docker pull` when running the image, but what if it is already running? – KansaiRobot Apr 20 '22 at 10:25
  • 1
    `docker rmi` will fail with an error message. – David Maze Apr 20 '22 at 10:29

0 Answers0