It’s been a while since I used Docker on my machine so I decided to clean things up. When I launched Docker, it prompted me to upgrade. Half a gig but easy to get that out of the way at least.
Then I ran “docker images” and was reminded that I haven’t done a good job of keeping this clean. I had:
- the original docker-whale play
- a bunch of experiments from when I didn’t know what I was doing (some of which have unnamed layers so I don’t even know what they are)
- some Java 9 early access edition stuff
- following along with the “Kubernetes in Action” book when I was the Technical Development Editor
- a lab I went to
Note: i’m not sure if any of this is a good way of doing things. But it worked for me.
Deleting the images the slow way
Yuck. I decided to delete all the images. For some, it was easy. Just run “docker rmi <imageHash>”.
For some, I got
Error response from daemon: conflict: unable to delete xxx (cannot be forced) - image has dependent child images
I also tried running “docker rmi $(docker images -a -q)” to delete all the images. This deleted some, but gave the same dependent child images error.
Great, I don’t know what they are. Luckily, StackOverflow had a command to find the children.
for i in $(docker images -q) do docker history $i | grep -q xxx && echo $i done | sort -u
I also got:
Error response from daemon: conflict: unable to delete xxx (must be forced) - image is referenced in multiple repositories
For these, it was just a matter of running “docker -rmi –force xxx.”
Deleting the images the fast way
I deleted the rest of the images with:
“docker rmi –force $(docker images -a -q)”
Containers and volumes
I did a far better job of cleaning these up!
docker ps -a
docker volume ls