root@server:~# docker images -a
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
<none> <none> 5e2dfc857e73 5 days ago 261.6 MB
<none> <none> d053e988f23d 5 days ago 261.6 MB
<none> <none> 1d5d4a2d89eb 5 days ago 261.6 MB
<none> <none> ea0d189fdb19 5 days ago 100.5 MB
<none> <none> 26c6175962b3 5 days ago 100.5 MB
<none> <none> 73d5cec4a0b3 5 days ago 100.5 MB
<none> <none> e19590e1bac1 5 days ago 100.5 MB
I've tried the following:
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
And the following:
docker rmi $(docker images -f "dangling=true" -q)
Get the following error:
docker: "rmi" requires a minimum of 1 argument.
See 'docker rmi --help'.
Usage: docker rmi [OPTIONS] IMAGE [IMAGE...]
Remove one or more images
docker rmi -f $(docker images -a|awk 'NR > 1 && $2 == "" {print $3}')
I have found
docker image prune -f
most useful and I use it all the time during my day to day work, using the tag-f
will not prompt for confirmation. More details hereTo remove dangling images please use :
Please refer to my answer here for a more detailed description : https://unix.stackexchange.com/a/445664/292327
You can go
docker rmi $(docker images -f "dangling=true" -q)
. See the images documentation for more options.You can try this simply
docker image prune removes all dangling images (those with tag none). docker image prune -a would also remove any images that have no container that uses them.
The difference between dangling and unused images is explained in this stackoverflow thread.