04.09.2023

Docker Container Listing

Docker is a platform, based on open source, that automatizes the process of deploying, scaling, and managing applications by utilizing containerization. Through Docker containers, developers can bundle applications and their dependencies into a single unit that can be executed on any Docker-supported platform. When working with Docker containers, it's valuable to have information about actively starting containers and ports they utilize. The command "docker ps" is employed for this specific purpose. Let's delve deeper into this command.

Discover command syntax:

docker ps [OPTIONS]

Options:

Examples of usage

Display a list of all the currently active containers:

docker ps

Screenshot №1. Show all containers

Retrieve a comprehensive list of all containers, including both those that are currently running and those that have been stopped:

docker ps -a

Screenshot №2. Show all include stopped

Print container IDs:

docker ps -q

Show details about the most recently created 5 containers:

docker ps -n 5

Display information about containers with certain filters. For example, named "webapp":

docker ps -f name=webapp

Show the sizes of the containers:

docker ps -s

Screenshot №3. Display size of containers

Output information about containers in a specific format. To illustrate, to only showcase the identifiers and names of the containers:

docker ps --format "{{.ID}} {{.Names}}"

Screenshot №4. Show info about containers in specific view

Thus, the "docker ps" command is a powerful tool for displaying information about Docker containers. By utilizing this feature, you can obtain a comprehensive summary of the existing container status and effortlessly sort the output by diverse parameters.