Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker cannot remove all images

i'm using Docker Desktop for Windows. When I try to remove all of my images by this command:

docker rmi $(docker images -q)

I got this error message in command prompt:

unknown shorthand flag: 'q' in -q)

I'm running Docker on Window 10 Pro

like image 900
Lee Avatar asked Oct 15 '25 13:10

Lee


1 Answers

Syntax is unix specific, so you change your command for Windows and you'll need to run the whole command in PowerShell or CMD.

remove containers:

powershell "docker ps -a -q | foreach-object { $i = $PSItem.ToString(); $cmd = 'docker'; & $cmd 'rm' '-f' $i }"

remove images:

powershell "docker images -a -q | foreach-object { $i = $PSItem.ToString(); $cmd = 'docker'; & $cmd 'rmi' '-f' $i }"
like image 189
javasenior Avatar answered Oct 18 '25 07:10

javasenior



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!