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:
Options:
- **-a, --all**: List all containers, including stopped ones;
- **-f, --filter**: Filter output using conditions;
- **-n, --last N**: Show only the N most recently created containers;
- **-q, --quiet**: Print container IDs only;
- **-s, --size**: Print container sizes (including all mounted volumes);
- **--format**: Set output format;
- **--no-trunc**: Do not truncate output (show all information).
Examples of usage
Display a list of all the currently active containers:
Retrieve a comprehensive list of all containers, including both those that are currently running and those that have been stopped:
Print container IDs:
Show details about the most recently created 5 containers:
Display information about containers with certain filters. For example, named "webapp":
Show the sizes of the containers:
Output information about containers in a specific format. To illustrate, to only showcase the identifiers and names of the containers:
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.