LinuxCommandLibrary

docker-ps

List running Docker containers

TLDR

View documentation for the original command

$ tldr docker container ls
copy

SYNOPSIS

docker ps [OPTIONS]

PARAMETERS

-a, --all
    Show all containers (default shows only running)

-q, --quiet
    Only display container IDs

-l, --latest
    Show the latest container (includes non-running)

-n, --last int
    Show n last created containers (includes non-running)

-s, --size
    Display sizes (virtual and writable layer)

--no-trunc
    Do not truncate output

-f, --filter filter
    Filter output based on conditions (e.g., status=running)

--format string
    Pretty-print using Go template

-t, --timestamps
    Show timestamps (DEPRECATED; use --format)

DESCRIPTION

The docker ps command displays information about Docker containers on the local host managed by the Docker daemon. By default, it lists only running containers in a tabular format with columns: CONTAINER ID, IMAGE, COMMAND, CREATED, STATUS, PORTS, and NAMES.

This tool is essential for container orchestration, allowing users to quickly inspect active workloads, check resource usage indirectly via status, and identify containers by name or ID for further actions like stopping or logging.

Options extend functionality: show all containers (including stopped) with -a, limit to latest or last n with -l or -n, filter by criteria like status or name using -f, or format output with Go templates via --format. Quiet mode (-q) outputs only IDs, useful in scripts. Size info (-s) reveals virtual and writable layer sizes.

It's non-interactive, relies on the Docker socket or API, and reflects the daemon's state. Common use: monitoring production environments or debugging deployments.

CAVEATS

Only lists containers on the connected Docker daemon; requires daemon access. Default output truncated for readability. Filters use exact matching unless specified.

COMMON EXAMPLES

docker ps -a (all containers)
docker ps -q (IDs only for scripting)
docker ps --format "table {{.Names}}\t{{.Status}}" (custom table)

COLUMN DETAILS

STATUS shows uptime like 'Up 2 hours'; PORTS lists mappings e.g., '0.0.0.0:80->80/tcp'; use --no-trunc for full commands.

HISTORY

Introduced in Docker 0.7.0 (2014) as core CLI command; evolved with filters and formatting in Docker 1.13+ (2017). Maintained by Docker Inc./Moby project.

SEE ALSO

docker(1), docker images(1), docker stop(1), docker logs(1)

Copied to clipboard