Search code examples
docker

How to remove docker images based on name?


I want to delete all versions of docker images with names that contain a given string (imagename).
I have tried the below, but it doesn't seem to work:

docker images | grep 'imagename' | xargs -I {} docker rmi


Solution

  • Try the following:

    docker rmi $(docker images | grep 'imagename')
    

    or

    docker rmi $(docker images 'imagename')
    

    or even:

    docker rmi $(docker images 'completeimagename' -a -q)
    

    In Windows PowerShell:

    docker rmi $(docker images --format "{{.Repository}}:{{.Tag}}"|findstr "imagename")