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
Running that will stop all containers without you having to cd
into other directories.
Top comments (0)