I'm using Docker for Mac and for saving disk space I want to get rid of some unused local images. As far as I know the local files are stored in ~/Library/Containers/com.docker.docker.
But even if I remove all images and containers from docker the folder keeps it's size of some GB and not a single byte is released. The only option is to remove the com.docker.docker folder completely but this makes only sense if you want to remove all the data and not only the unused images. What am I doing wrong?
To remove all unused images, use docker images prune
.
There's also another way to remove all unused image (dangling): docker rmi $(docker images -aq --filter dangling=true)
To remove images you do no need, use docker rmi <image>
. You may use multiple images, eg. docker rmi abcdef ghijkl
, where abcdef
and ghijkl
are image hashes.
If this does not help immediately, try restarting your docker service (sudo service docker restart
). In some cases images/containers are only marked as deleted
and are not removed. But they are after restart.