Docker Config Reference (ps)
docker ps is the defacto docker container listing command, here are numerous examples for using it
docker ps
This command enumerates all currently active containers on the Docker host, presenting details such as container identifier, associated image, executed command, creation timestamp, operational status, exposed ports, and assigned names. It serves as the fundamental tool for monitoring running containers, enabling administrators to assess real-time workload distribution and identify potential issues without including stopped or terminated instances. Example:
docker ps -a
Employing the -a or --all flag, this command lists every container on the host, encompassing those that are running, paused, stopped, or exited. It provides a comprehensive inventory of container history, which is invaluable for auditing past executions, diagnosing failures, or managing resource cleanup in environments with transient workloads. Example:

docker ps -q
The -q or --quiet option restricts output to solely the container identifiers of running containers, omitting additional metadata. This concise format is particularly advantageous for scripting purposes, such as piping identifiers into subsequent commands for batch operations like stopping or removing multiple containers efficiently. Example:
root@28b3984ca3:~# docker ps -q
199eb8717a36
54b46b2da9cf
d4ac4c25742f
0e50dcea1eb4
cc5f574e2982
a6f25cf1cc13
9cc5a868eed5
27f1ede95bb7
49ea303467ed
aa3b2a752de4
dbef901559c4
0c2dc9266c3a
8aa05906555c
40a9e421aa17
docker ps --format "{{.ID}} {{.Names}}"
This command customizes the output using a Go template to display only the container identifier and name for running containers. It facilitates tailored reporting, allowing selective extraction of attributes for integration with monitoring systems or automated workflows where specific data points are required without extraneous information.
root@28b3984ca3:~# docker ps --format "{{.ID}} {{.Names}}"
199eb8717a36 ssh-container
54b46b2da9cf traffic_monitor
d4ac4c25742f honeypots.vpscoder.com
0e50dcea1eb4 proxy-manager
cc5f574e2982 goaccess
docker ps --filter "status=running"
Utilizing the --filter option with the status criterion, this command lists only containers that are currently in a running state. It enables precise querying for operational containers, supporting tasks such as performance monitoring or ensuring service availability in production environments.
docker ps -s
The -s or --size flag augments the output with details on the writable layer size and virtual size of running containers. This is essential for resource management, as it reveals storage consumption patterns, aiding in the identification of bloated containers or optimization opportunities. This puts out lots of details!

It should be noted that some containers are really tiny! For instance the ssh-container was only 38.2 kB! Small!
docker ps --no-trunc
This command displays running containers without truncating lengthy fields such as identifiers, commands, or names. It ensures complete visibility of detailed information, which is critical for accurate analysis in scenarios involving complex commands or extended container labels. This gives out the FULL container name:

docker ps -l
The -l or --latest flag lists solely the most recently created container, regardless of its state. It is useful for quick verification following container instantiation, particularly in automated build processes or when troubleshooting the outcome of recent deployments.
docker ps --filter "name=mycontainer"
This command filters containers by name, listing only those matching "mycontainer" in running state. It supports targeted inspections in multi-container setups, streamlining management by isolating specific services or applications.
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Status}}"
Employing a tabular format with selected columns (identifier, image, and status), this command enhances readability for human operators. It is suitable for generating structured reports or dashboards, providing a clear summary of essential container attributes.
docker ps -f "label=com.example.app=web"
The -f shorthand for --filter lists running containers with the specified label "com.example.app=web". This facilitates organization and querying based on metadata, enabling efficient grouping of containers by application type or environment in labeled infrastructures.
docker ps -a -q
Combining -a for all containers and -q for identifiers only, this command outputs IDs of every container, including non-running ones. It is ideal for bulk operations, such as removing all containers via scripting, while minimizing output verbosity.
docker ps -s --format "{{.Names}} {{.Size}}"
This command displays container names and sizes using a custom format for running containers. It assists in storage audits, allowing quick identification of resource-intensive instances for optimization or cleanup.
docker ps --filter "ancestor=nginx"
Filtering by ancestor image "nginx", this command lists running containers derived from that image. It supports image-based management, useful for updating or monitoring specific application versions across the host.
docker ps --filter "before=containerid"
This command lists running containers created before the specified "containerid". It enables chronological filtering, aiding in the analysis of container lifecycle or identifying outdated instances in sequential deployments.
docker ps --filter "since=containername"
Filtering containers created after "containername", this command focuses on newer instances. It is beneficial for post-deployment reviews or isolating recently launched services in dynamic environments.
docker ps --filter "volume=/data"
This command lists running containers that mount the volume "/data". It facilitates storage dependency tracking, ensuring data persistence configurations are verified across relevant containers.
docker ps --filter "network=mynet"
Filtering by network "mynet", this command displays running containers attached to that network. It supports network topology analysis, essential for debugging connectivity or isolating segmented services.
docker ps --filter "health=healthy"
This command lists running containers with a "healthy" healthcheck status. It enables monitoring of application health, allowing proactive intervention based on defined health criteria.
docker ps --filter "is-task=true"
Filtering for task containers in Swarm mode, this command lists running tasks. It is crucial for orchestrated environments, providing visibility into distributed workloads.
docker ps --format json
This command outputs running container details in JSON format. It is designed for programmatic consumption, integrating seamlessly with APIs or tools requiring structured data.
docker ps -n 5
The -n flag limits output to the last 5 created running containers. It provides a focused view on recent activity, useful for quick status checks in high-turnover systems.
docker ps --no-trunc --format "{{.Command}}"
This displays full, untruncated commands for running containers. It aids in command-line argument verification, essential for debugging configuration issues.
docker ps -a -q -f "status=exited"
Combining options, this lists IDs of all exited containers. It supports cleanup scripts, identifying terminated instances for removal.
docker ps --filter "publish=80"
This command lists running containers publishing port 80. It verifies external exposure, critical for service accessibility checks.
docker ps --filter "expose=8080"
Filtering for exposed port 8080, this lists running containers with internal exposure. It assists in internal network configuration reviews.
docker ps --filter "id=partialid"
This command lists running containers matching the partial ID. It enables quick lookup when full IDs are not known.
docker ps --help
This command displays documentation for docker ps, including options and usage. It serves as a reference for command syntax.
docker ps -a --format "{{.ID}} {{.Status}} {{.Names}}"
This lists all containers with ID, status, and names. It provides a customized summary for comprehensive overviews.
docker ps --filter "label=env=prod"
Filtering by label "env=prod", this lists running production containers. It supports environment-specific management.