To stop Docker containers, you can use the docker stop command followed by the name or ID of the container you want to stop. Here’s how to do it:
-
List Running Containers: First, you may want to see which containers are currently running. Use the following command:
docker ps -
Stop a Specific Container: Once you have the container name or ID, you can stop it with:
docker stop <container_name_or_id>For example:
docker stop my-nginx -
Stop Multiple Containers: You can also stop multiple containers at once by listing their names or IDs separated by spaces:
docker stop <container_id_1> <container_id_2> -
Stop All Running Containers: If you want to stop all running containers, you can use the following command:
docker stop $(docker ps -q)
This command retrieves the IDs of all running containers and stops them. Let me know if you need further assistance!
