Stop All Docker Compose Related Containers

Alan Johnson - Jul 11 '22 - - Dev Community

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.

. . . . . . . . . . . . .
Terabox Video Player