Home Cloud Computing How one can Cease & Take away All Docker Containers with 2 Instructions

How one can Cease & Take away All Docker Containers with 2 Instructions

0
How one can Cease & Take away All Docker Containers with 2 Instructions

[ad_1]

On this TechRepublic How one can Make Tech Work video, Jack Wallen exhibits how one can 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 approach too many Docker containers working and wished to simply blow all of them away and begin over. Granted, I wouldn’t do that on a manufacturing machine; however if you happen to’re engaged on a growth surroundings the place it doesn’t matter if you happen to kill each working container, then utilizing this nuclear possibility is an effective approach to go.

As an illustration, you may have to 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 every other container to remain working – there’s a a lot simpler resolution for this. What I’m about to point out 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, problem 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 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 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 bear in mind to make use of it correctly. When you’ve got 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 execs from Jack Wallen.

[ad_2]