📜  docker stop container by partial name (1)

📅  最后修改于: 2023-12-03 14:40:49.800000             🧑  作者: Mango

Docker Stop Container by Partial Name

When working with multiple Docker containers, it can be helpful to stop containers by their partial names instead of using the complete container ID. In this tutorial, we will discuss how to stop Docker containers by their partial names.

Prerequisites

Before you begin, make sure you have the following prerequisites:

  • Docker installed on your machine
  • Basic knowledge of Docker commands
Steps
  1. Open a terminal or command prompt.

  2. List all Docker containers using the following command:

    docker ps -a
    

    This will show you a list of all containers and their statuses.

  3. Identify the partial name of the container you want to stop. You can search for the container by name or other attributes, such as the image name or the command it's running.

  4. Once you have identified the container, stop it using the following command:

    docker container stop [partial name]
    

    Replace [partial name] with the partial name of the container you want to stop.

    For example, if you want to stop a container with the name "myapp-container", you can use the following command:

    docker container stop myapp
    

    This will stop the container with the partial name "myapp".

  5. Verify that the container has been stopped by running the following command:

    docker ps -a
    

    This will show you the list of all containers and their statuses. The container you just stopped should no longer be running.

Conclusion

In this tutorial, we discussed how to stop Docker containers by their partial names. This method can be especially useful when working with multiple containers and you don't want to use the complete container ID to stop them. By following these steps, you can easily stop a Docker container by its partial name.