Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows cmd docker command piping

I found this instruction on piping commands in Windows CMD:

The "pipe" redirects the output of a program or command to a second program or command.

Syntax:

Command1 | Command2

[Source] (at the very bottom)

Yet docker ps -aq | docker start or any similar combination just returns errors.

The only working combination to start all stopped container works in PowerShell.

docker start $(docker ps -a -q -f "status=exited")
like image 412
MattJ Avatar asked Mar 19 '26 20:03

MattJ


1 Answers

You can pipe into docker containers (-i), but you can't pipe arguments to the docker command itself.

In PowerShell use a loop for starting a list of stopped containers:

docker ps -a -q -f "status=exited" | ForEach-Object { docker start $_ }

In CMD use a loop for starting a list of stopped containers:

for /f "tokens=*" %i in ('docker ps -a -q -f "status=exited"') do docker start %i
like image 145
Ansgar Wiechers Avatar answered Mar 21 '26 17:03

Ansgar Wiechers



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!