When using docker, the image may take up space. It is troublesome to delete them one by one, so make a note of the command to delete untagged images at once. I will also summarize the meaning of command options.
docker rmi $(docker images -f "dangling=true" -q)
You can delete untagged images in bulk by running the above command.
Get untagged image by setting dangling to true with filter option
docker images -f "dangling=true"
#Execution result
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> c29504d0f8fd 2 weeks ago 1.21GB
<none> <none> e6325cdc18c4 2 weeks ago 1.18GB
Get ID only with quiet option
docker images -f "dangling=true" -q
#Execution result
c29504d0f8fd
e6325cdc18c4
Delete image using the obtained ID
docker rmi $(docker images -f "dangling=true" -q)
Please refer to the official document for details.
Docker docs|docker images https://docs.docker.com/engine/reference/commandline/images/ Docker docs|docker rmi https://docs.docker.com/engine/reference/commandline/rmi/
Recommended Posts