Sometimes, there are some untagged images left behind after failed builds. In order to get rid of those, this script can be used.
#!/bin/bash
docker rm $(docker ps -aq)
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
Hi! The last command could be:
docker rmi $(docker images -f "dangling=true" -q)
Hi,
One option that can be used during the image building period is
--force-rm
which will remove the intermediate containers despite the image is successfully built or not.So we dont need to remove unused intermediate containers