Cease & Take away All Docker Containers with 2 Instructions


On this TechRepublic Make Tech Work video, Jack Wallen reveals tips on how to cease and take away all Docker containers without delay with simply two easy instructions.

I can’t inform you what number of occasions I’ve had means too many Docker containers working and needed to simply blow all of them away and begin over. Granted, I wouldn’t do that on a manufacturing machine; however should you’re engaged on a improvement setting the place it doesn’t matter should you kill each working container, then utilizing this nuclear possibility is an effective approach to go.

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

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

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

As you’ll be able to 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 you probably have a number of containers working, it’ll both cease or take away them all of sudden. This command is available in very useful, although keep in mind to make use of it correctly. When you have any containers working 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 newest tech recommendation for enterprise professionals from Jack Wallen.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles