LinuxCommandLibrary

docker-container-ls

TLDR

List currently running Docker containers

$ docker [[ps|container ls]]
copy

List all Docker containers (running and stopped)
$ docker [[ps|container ls]] [[-a|--all]]
copy

Show the latest created container (includes all states)
$ docker [[ps|container ls]] [[-l|--latest]]
copy

Filter containers that contain a substring in their name
$ docker [[ps|container ls]] [[-f|--filter]] "name=[name]"
copy

Filter containers that share a given image as an ancestor
$ docker [[ps|container ls]] [[-f|--filter]] "ancestor=[image]:[tag]"
copy

Filter containers by exit status code
$ docker [[ps|container ls]] [[-a|--all]] [[-f|--filter]] "exited=[code]"
copy

Filter containers by status (created, running, removing, paused, exited, and dead)
$ docker [[ps|container ls]] [[-f|--filter]] "status=[status]"
copy

Filter containers that mount a specific volume or have a volume mounted in a specific path
$ docker [[ps|container ls]] [[-f|--filter]] "volume=[path/to/directory]" --format "table [.ID]\t[.Image]\t[.Names]\t[.Mounts]"
copy

SYNOPSIS

docker container ls [OPTIONS]

PARAMETERS

--all, -a
    Show all containers (default: running only). Incompatible with --last, -n

--filter, -f stringArray
    Filter by conditions: ancestor, container, exited, health, id, image, isolation, label, name, network, publish, etc.

--format string
    Pretty-print using Go template

--last, -n int
    Show n last created containers (default: all). Incompatible with --all, -a

--no-trunc
    Do not truncate output

-q, --quiet
    Display only numeric container IDs

--size, -s
    Display container and virtual sizes

DESCRIPTION

The docker container ls command (aliased as docker ps) lists Docker containers on the system. By default, it shows only running containers with key details: CONTAINER ID, IMAGE, COMMAND, CREATED, STATUS, PORTS, and NAMES.

This tool is essential for inspecting container states during development, debugging, and operations. Customize output with options to view all containers, apply filters (e.g., by status, name, or image), format as JSON or tables, limit to recent ones, suppress truncation, show sizes, or output only IDs for scripting.

For example, docker container ls -a displays all containers (running and stopped), while docker container ls -q lists only IDs. Filters like --filter status=paused narrow results. It integrates with Docker Engine's REST API under the hood, providing real-time snapshots without affecting running containers.

Ideal for CI/CD pipelines, server monitoring, and swarm clusters, it supports quiet mode for automation.

EXAMPLES

docker container ls
List running containers.

docker container ls -a -q
List all container IDs.

docker container ls --filter "status=exited"
Show exited containers.

NOTE

docker ps is an alias; use docker container ls for consistency with subcommands.

HISTORY

Introduced in Docker 0.7.0 (2014); docker ps alias added for backward compatibility. Evolved with filtering, formatting in Docker 1.13+; now part of Docker CLI v27+.

SEE ALSO

docker ps(1), docker-image-ls(1), podman ps(1)

Copied to clipboard