So, I have the following command
$(docker container ls -a -q) | docker container stop
to stop all my docker containers, which works great! Except when I've just wiped clean all of them:
"docker container stop" requires at least 1 argument.
See 'docker container stop --help'.
Usage: docker container stop [OPTIONS] CONTAINER [CONTAINER...]
Stop one or more running containers
Is there any way I can prevent this error message from showing up using a single line command?
Note: my original command was actually docker container stop $(docker container ls -a -q)
, which gives the same error message, but I tought it would be easier to describe my problem using pipe/chain one command to the other. Answers for both commands are OK, but I'll prefer to use docker container stop $(docker container ls -a -q)
$(docker container ls -a -q) | docker container stop
doesn't work great at all. At the very least if you wanted to use a pipe that should bedocker container ls -a -q | xargs docker container stop