How to list running containers by name?

Listing Running Containers by Name

To list the running Docker containers by name, you can use the docker ps command with the -f (filter) option. This will allow you to filter the output based on the container name.

Here's the basic command:

docker ps -f name=<container_name>

Replace <container_name> with the name of the container you want to list. If you want to list all running containers, you can omit the -f name=<container_name> part.

Here's an example:

docker ps -f name=my-web-app

This will list all the running containers with the name "my-web-app".

You can also use the --format option to customize the output. For example, to display only the container names:

docker ps -f name=my-web-app --format "{{.Names}}"

This will output the container names in a more readable format.

Here's a Mermaid diagram that explains the key steps:

graph TD A[Run Docker Containers] --> B[List Running Containers] B --> C[Filter by Container Name] C --> D[Display Container Names]

The diagram shows that to list the running containers by name, you first need to run the Docker containers, then use the docker ps command to list the running containers, filter the output by the container name, and finally display the container names.

This approach is useful when you have multiple containers running and you need to quickly identify a specific container by its name. It can be particularly helpful when managing complex Docker environments with many running containers.

0 Comments

no data
Be the first to share your comment!