Stop every running Docker container with Nu's splat operator

Today I Learned · August 2, 2026

Stop every running Docker container with Nu’s splat operator

Stop all running containers in one command using nushell’s splat operator:

docker stop ...(docker ps -q | lines)

Stage by stage

Stage What it does
docker ps -q Prints only the container IDs, one per line (quiet mode, no headers)
| lines Splits that text into a nushell list of IDs
...(...) The splat operator expands the list into separate positional arguments
docker stop ... Stops every container in a single invocation

It effectively expands to:

docker stop <id-1> <id-2> <id-3>

Why splat is the trick

docker ps -q returns text, while docker stop wants individual arguments. lines turns the text into a list, and ... (splat) flips that list back into separate arguments — no for loop, no xargs.

Gotchas