docker compose ps command
The docker compose ps command lists containers related to a Docker Compose project and their status.
docker compose ps can display information such as the running status and port mappings of all service containers in the current project.
Syntax
docker compose ps [OPTIONS] [SERVICE...]
- SERVICE(Optional): Specifies the name of the service whose status to view. If not specified, the container status of all services will be listed.
OPTIONS:
-a, --all: Lists all containers, including stopped ones.-q, --quiet: Shows only container IDs, no other information.--services: Lists only service names, without detailed container information.--filter: Filters the output based on conditions. For example, you can filter containers by status.
Output information
- Name: Container name.
- Command: The command running in the container.
- State: Container status (such as Up, Exited).
- Ports: Container port mappings.
Example
1. List all running containers
docker compose ps
Shows the containers currently running in the project and their status.
** 2. List all containers (including stopped ones)**
docker compose ps -a
Lists the status of all containers, including stopped ones.
** 3. Show only container IDs**
docker compose ps -q
Only returns container IDs, without other detailed information.
** 4. List the names of all services**
docker compose ps --services
Shows only service names, without listing detailed container information.
** 5. Filter containers by status**
docker compose ps --filter "status=running"
Only lists containers with status "running".
Docker Command Reference