← 返回命令列表

Linux command

docker-ps 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

List running containers

docker ps

List all containers

docker ps -a

List with custom format

docker ps --format "{{.ID}}: {{.Names}}"

List only container IDs

docker ps -q

List containers by name filter

docker ps -f name=[pattern]

List containers by status

docker ps -f status=[running|exited|paused]

Show container sizes

docker ps -s

List last created container

docker ps -l

说明

docker ps lists Docker containers. By default, it shows only running containers with their ID, image, command, creation time, status, ports, and names. The command provides filtering capabilities to find specific containers by various criteria. Custom formatting allows displaying exactly the information needed, useful for scripting and automation. Container IDs are shown truncated by default; use --no-trunc for full IDs. The -q option outputs only IDs, convenient for passing to other commands.

参数

-a, --all
Show all containers (default shows running only).
-q, --quiet
Only display container IDs.
-l, --latest
Show latest created container.
-n _num_
Show n last created containers.
-s, --size
Display total file sizes.
-f, --filter _filter_
Filter output based on conditions.
--format _string_
Format output using Go template.
--no-trunc
Don't truncate output.

FAQ

What is the docker-ps command used for?

docker ps lists Docker containers. By default, it shows only running containers with their ID, image, command, creation time, status, ports, and names. The command provides filtering capabilities to find specific containers by various criteria. Custom formatting allows displaying exactly the information needed, useful for scripting and automation. Container IDs are shown truncated by default; use --no-trunc for full IDs. The -q option outputs only IDs, convenient for passing to other commands.

How do I run a basic docker-ps example?

Run `docker ps` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a, --all do in docker-ps?

Show all containers (default shows running only).