Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 896
user3691223 Avatar asked Mar 30 '26 00:03

user3691223


2 Answers

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.

like image 59
BMitch Avatar answered Apr 02 '26 04:04

BMitch


I used this in Windows:

powershell docker stop $(docker ps -aq)
like image 42
Prophet Daniel Avatar answered Apr 02 '26 03:04

Prophet Daniel