Harry Uglow
Harry Uglow

Reputation: 307

How do I delete local Docker images by repository?

I have a bunch of docker images I want to get rid of and it would be convenient if I could remove them by specifying the repository name as it appears when I run docker images. For example if docker images returns:

REPOSITORY      TAG              IMAGE ID            CREATED             SIZE
ui_test         191127_manual    41a7ca9824d6        24 hours ago        1.42GB
ui              git-24fa8d1a     cdd254eff918        24 hours ago        1.44GB
ui              git-31a4b052     9b4740060a62        25 hours ago        1.45GB
ui_test         191122_manual    ba9cb04ce2d8        6 days ago          1.39GB
ui              git-68110e426    f26ef80abc25        6 days ago          1.38GB

what command would I use to remove all of the ui_test images?

Upvotes: 3

Views: 911

Answers (1)

Maroun
Maroun

Reputation: 95958

You can pass image IDs you want to delete to docker rmi:

docker rmi $(docker images -q 'ui_test')

From the docs:

The docker images command takes an optional [REPOSITORY[:TAG]] argument that restricts the list to images that match the argument. If you specify REPOSITORYbut no TAG, the docker images command lists all images in the given repository.

Upvotes: 2

Related Questions