DEV Community

Alan Johnson
Alan Johnson

Posted on • Edited on • Originally published at nalanj.dev

2 1

Stop All Docker Compose Related Containers

I jump around between projects very frequently, and often those projects use Docker Compose. When moving around I typically go to start Docker Compose in the project I'm about to work on, realize I left it running in another, and then have to cd back to the other directory, stop things, and then cd back.

Today I finally decided to fix the problem. Here's a one-liner that will stop all Docker Compose related containers across your system, regardless of directory:

docker ps -q --filter label=com.docker.compose.project.working_dir | xargs docker stop
Enter fullscreen mode Exit fullscreen mode

Running that will stop all containers without you having to cd into other directories.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay