How to Stop Docker Container Command | Stop Single-Multi Container


Today we will know how to stop the docker container command. There are different commands for stopping containers. Because there could be different situations.

Where you need to stop Single container, Multiple container, and All containers. So based on your situation you can use anyone of them. So let’s get started now.

How to Stop Docker Container Command

Stop Single Running Container Command

If you want to stop a single running container. Then the name or the ID of that container. And execute them with the help of command as shown below.

sudo docker stop <container-id>

Stop Multiple Running Container Command

When you are required to stop more than one container at a time. Then it is also possible. You will need to select the name or ID of those containers. After that you can use them in the below command.

sudo docker stop <container-id> <container-id> <container-id>

Stop All Running Container Command

But if you face a situation where you need to stop all the running containers due to some issue. You can also do that very easily. For that you will not need to select the container name or ID. Because in this command those things are not required. That’s the best thing when using this command. So you can check the command below.

sudo docker stop $(sudo docker ps -aq)

Prerequisites

When you want to stop the container. Then there must be a running container on your system. If you do not have any running containers. Then first go and create the docker container.

But, if you want to see how you create a docker container from your own. Then please follow the below description.

Create Docker Container Command

Here I will show you, how you can easily create your docker container from the start. Because, I have described it in a very simple language. So that everyone can understand this.

Conclusion

In conclusion, we have completed how to stop docker container commands. And the way for stopping containers according to your requirements. Also we have covered the prerequisites before stopping the container.

I hope this article was very helpful to all of you.

Thank you very much for giving your time.