user3691223
user3691223

Reputation: 353

Windows docker command line cannot accept inner commands

I have windows docker installed and when I run this on command line:

docker stop $(docker ps -q)

I get:

unknown shorthand flag: 'q' in -q)

But when running:

docker ps -q

Everything is alright. Any clues?

Upvotes: 3

Views: 1290

Answers (4)

JohnC
JohnC

Reputation: 3257

You can also enable Bash shell within Powershell on recent releases of Windows 10 and the use the $ command

Upvotes: 0

Prophet Daniel
Prophet Daniel

Reputation: 327

I used this in Windows:

powershell docker stop $(docker ps -aq)

Upvotes: 2

Nigrimmist
Nigrimmist

Reputation: 12358

You can try a little trick to stop all containers :

docker ps -a -q | xargs -n 1 -P 8 -I {} docker stop {}

It does not contain $ symbol, so should be correct

Upvotes: 0

BMitch
BMitch

Reputation: 263637

The $(sub command) is a syntax of the bash shell (along with many other command shells on Linux). If you try to run this from a Windows command prompt, it will not be correctly expanded before running the rest of the command and you'll see the errors you're encountering. Try installing and running the commands on bash for Windows.

Upvotes: 2

Related Questions