2020-09-08 17:19:52 +01:00
|
|
|
# docker ps
|
|
|
|
|
|
|
|
> List Docker containers.
|
2024-09-08 16:41:05 +01:00
|
|
|
> More information: <https://docs.docker.com/reference/cli/docker/container/ls/>.
|
2020-09-08 17:19:52 +01:00
|
|
|
|
2024-03-14 05:01:06 +00:00
|
|
|
- List currently running Docker containers:
|
2020-09-08 17:19:52 +01:00
|
|
|
|
|
|
|
`docker ps`
|
|
|
|
|
2024-03-14 05:01:06 +00:00
|
|
|
- List all Docker containers (running and stopped):
|
2020-09-08 17:19:52 +01:00
|
|
|
|
|
|
|
`docker ps --all`
|
|
|
|
|
|
|
|
- Show the latest created container (includes all states):
|
|
|
|
|
|
|
|
`docker ps --latest`
|
|
|
|
|
|
|
|
- Filter containers that contain a substring in their name:
|
|
|
|
|
2024-04-18 19:38:25 +01:00
|
|
|
`docker ps --filter "name={{name}}"`
|
2020-09-08 17:19:52 +01:00
|
|
|
|
|
|
|
- Filter containers that share a given image as an ancestor:
|
|
|
|
|
|
|
|
`docker ps --filter "ancestor={{image}}:{{tag}}"`
|
|
|
|
|
|
|
|
- Filter containers by exit status code:
|
|
|
|
|
|
|
|
`docker ps --all --filter="exited={{code}}"`
|
|
|
|
|
|
|
|
- Filter containers by status (created, running, removing, paused, exited and dead):
|
|
|
|
|
2024-04-18 19:38:25 +01:00
|
|
|
`docker ps --filter "status={{status}}"`
|
2020-09-08 17:19:52 +01:00
|
|
|
|
|
|
|
- Filter containers that mount a specific volume or have a volume mounted in a specific path:
|
|
|
|
|
2024-04-18 19:38:25 +01:00
|
|
|
`docker ps --filter "volume={{path/to/directory}}" --format "table {{.ID}}\t{{.Image}}\t{{.Names}}\t{{.Mounts}}"`
|