when I run a command such as sudo docker rmi me/myimage I get the responce ...image untagged, but, when I rerun sudo docker images I can see that this \"untagged\" image i
If John Petrone solution doesn't work, try removing those images referring explicitly the IMAGE ID
you see when you run docker images
. You can remove all of them with one command
for i in
sudo docker images | grep \ | awk '{print $3}'; do sudo docker rmi $i; done
PD: I don't know John Petrone answer. It works nicely with Docker 1.4.1
This commands also work
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
Delete images with force to forgo stopped containers that might be using image
docker rmi -f $(docker images | grep "^<none>" | awk '{print $3}')
This command will remove all the dangling images and containers from docker.
docker system prune -f
First you need to remove exited containers, then remove dangling images.
docker rm $(docker ps -q -f status=exited)
docker rmi $(docker images -q -f dangling=true)
After all, I created the below script as ~/bin/dclean and have been using it.
#!/bin/sh
processes=$(docker ps -q -f status=exited)
if [ -n "$processes" ]; then
docker rm $processes
fi
images=$(docker images -q -f dangling=true)
if [ -n "$images" ]; then
docker rmi $images
fi
You should be able to remove untagged Docker images using the "dangling=true"
flag:
sudo docker rmi $(sudo docker images -f "dangling=true" -q)
source:
https://docs.docker.com/engine/reference/commandline/images/
you can delete single images by their image id...
docker images
docker rmi <image-id>