Listing Running Docker Containers
Once you have Docker containers running, you may need to list and manage them. To list the running Docker containers, you can use the docker ps
command.
Listing Running Containers
To list all the running Docker containers, use the following command:
docker ps
This will display a table with information about the running containers, including the container ID, the image used to create the container, the command being executed, the time the container was created, the status, and the ports.
You can also add additional options to the docker ps
command to customize the output. For example:
docker ps -a
This will list all containers, including those that are not currently running.
docker ps --format "{{.ID}}\t{{.Image}}\t{{.Status}}"
This will display the container ID, image, and status in a tabular format.
Filtering Running Containers
You can also filter the list of running containers using various options. For example:
docker ps -f "status=running"
This will only list the containers that are currently running.
docker ps -f "name=mycontainer"
This will only list the containers with the name "mycontainer".
docker ps --format "{{.ID}}\t{{.Image}}\t{{.Status}}" -f "status=running"
This will list the container ID, image, and status for all running containers in a tabular format.
By understanding how to list running Docker containers, you can easily manage and monitor the containers in your Docker environment.