2

I'm kinda new to docker but has some fair knowledge about it. Recently I wanted to list down the my docker images, so I ran docker image ls, which gives me a bit of large list of pulled images..

Part of the image list

Above list shows the part of the image list in the machine. I have some knowledge about this <none> images which are known as intermediate images. But the problem is they are huge some images are almost 1GB. To my knowledge I never ran a single huge container other than gitlab. When I was done with it I removed the image. Can someone explain why these intermediate images are large and way to get rid of it without damaging other image layers?

Govinda Malavipathirana
  • 1,095
  • 2
  • 11
  • 29
  • 3
    [`docker image prune`](https://docs.docker.com/engine/reference/commandline/image_prune/) should do the trick. – spender Dec 04 '19 at 16:57
  • Any reason for this 'large' behavior of the images? – Govinda Malavipathirana Dec 04 '19 at 17:00
  • 1
    Usually, these hanging images are intermediate images... artefacts of docker-build. It's useful to keep them around because it can really speed up builds if you don't make changes to lower layers of the dockerfile... but yes, they can end up consuming significant amounts of storage left unchecked. – spender Dec 04 '19 at 17:07
  • You may also find the following answer helpful: https://devops.stackexchange.com/a/5253/7730 – BMitch Dec 04 '19 at 17:07

2 Answers2

1
docker system prune

Is your friend to clean up so called "dangling images" (among other things), for more background information please refer to the following thread: What is a dangling image and what is an unused image?

Till Kuhn
  • 1,054
  • 11
  • 17
1
docker container prune   # Remove all stopped containers
docker volume prune      # Remove all unused volumes
docker image prune       # Remove unused images
docker system prune      # All of the above, in this order: containers, volumes, images
docker system df         # Show docker disk usage, including space reclaimable by pruning
Agustus
  • 634
  • 1
  • 7
  • 24