Overview of docker ps
`docker ps` is an essential command for quickly understanding the status of Docker containers. It primarily shows running containers by default, but you can use various options to view stopped containers, or containers with specific conditions in detail.
Explanation of Output Columns
When executing the `docker ps` command, the following information is typically displayed:
Key Columns
- CONTAINER ID: The unique identifier of the container.
- IMAGE: The image used to create the container.
- COMMAND: The command that is executed when the container starts.
- CREATED: The time when the container was created.
- STATUS: The current state of the container (e.g., Up, Exited) and its running time.
- PORTS: Information about the container's port mapping.
- NAMES: The name of the container (if not specified, Docker assigns a random one).
Key Options
These are useful options that can be used with the `docker ps` command. Try combining these options to accurately retrieve the container information you want.
1. Basic View Options
2. Filtering Options
3. Output Formatting Options
Generated command:
Try combining the commands.
Description:
`docker ps` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Learn how to effectively view and manage container lists through various usage examples of the `docker ps` command.
View All Currently Running Containers
docker ps
This is the most basic `docker ps` command. It shows only the containers that are currently active.
View All Containers, Including Stopped Ones
docker ps -a
You can see a list of all containers, whether they are running or stopped, at a glance.
View Only Containers Created from the Nginx Image
docker ps --filter "ancestor=nginx"
Filters and shows only containers created based on a specific image (in this case, Nginx).
View Only IDs of Exited Containers
docker ps -aq --filter "status=exited"
Outputs only the IDs of containers in the 'Exit' state, which is useful for using these IDs as input for other commands (e.g., `docker rm`).
Output Only Container Names and Status
docker ps --format "table {{.Names}}\t{{.Status}}"
Selects and outputs only the desired columns (name and status) in a table format.
Display Full Information for the Latest 3 Containers
docker ps -n 3 --no-trunc
Displays untruncated, detailed information for the three most recently created containers.