How to stop Docker containers?

091

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:

  1. List Running Containers: First, you may want to see which containers are currently running. Use the following command:

    docker ps
  2. 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
  3. 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>
  4. 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!

0 Comments

no data
Be the first to share your comment!