Learn how to Cease & Take away All Docker Containers with 2 Instructions

On this TechRepublic Learn how to Make Tech Work video, Jack Wallen reveals learn how to cease and take away all Docker containers directly with simply two easy instructions.

I can’t let you know what number of instances I’ve had method too many Docker containers operating and needed to only blow all of them away and begin over. Granted, I wouldn’t do that on a manufacturing machine; however in case you’re engaged on a growth atmosphere the place it doesn’t matter in case you kill each operating container, then utilizing this nuclear choice is an effective option to go.

For example, you would possibly must deploy a brand new testing container on a port that another take a look at container is utilizing. As a substitute of monitoring that container down – and so long as you don’t want some other container to remain operating – there’s a a lot simpler resolution for this. What I’m about to indicate you does precisely what it feels like.

The primary command will cease all operating containers, and the second command deletes them. It really works each time. Right here’s the way you do it.

To cease all your operating Docker containers, subject the command docker cease $(docker ps -a -q). The subsequent command removes all containers, which is docker take away $(docker ps -a -q).

As you may see, there are two instructions: docker take away (or cease) and docker ps -a -q. The primary command makes use of the output of the second command as a variable, so if in case you have a number of containers operating, it’ll both cease or take away them . This command is available in very useful, although bear in mind to make use of it correctly. In case you have any containers operating that should stay up, you’re higher off stopping and eradicating the containers manually.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the most recent tech recommendation for enterprise professionals from Jack Wallen.