Solution to "unknown shorthand flag a in -a" When Trying to Remove Docker Containers

This docker command will remove all stopped containers.

docker rm $(docker ps -a -q)

This docker command will remove all containers, even if they are running.

docker rm $(docker ps -a -q) -f

If you run this command in a regular Windows Command prompt you will get the following output:

C:\>docker rm $(docker ps -a -q)
unknown shorthand flag: 'a' in -a
See 'docker rm --help'.

The solution is to run this command in a PowerShell terminal or the Docker QuickStart Terminal.


Jon