docker container ls

Estimated reading time: 5 minutes

Description

List containers

Usage

docker container ls [OPTIONS]

Options

Name, shorthand Default Description
--all, -a false Show all containers (default shows just running)
--filter, -f   Filter output based on conditions provided
--format   Pretty-print containers using a Go template
--last, -n -1 Show n last created containers (includes all states)
--latest, -l false Show the latest created container (includes all states)
--no-trunc false Don’t truncate output
--quiet, -q false Only display numeric IDs
--size, -s false Display total file sizes

Parent command

Command Description
docker container Manage containers
Command Description
docker container attach Attach to a running container
docker container commit Create a new image from a container’s changes
docker container cp Copy files/folders between a container and the local filesystem
docker container create Create a new container
docker container diff Inspect changes to files or directories on a container’s filesystem
docker container exec Run a command in a running container
docker container export Export a container’s filesystem as a tar archive
docker container inspect Display detailed information on one or more containers
docker container kill Kill one or more running containers
docker container logs Fetch the logs of a container
docker container ls List containers
docker container pause Pause all processes within one or more containers
docker container port List port mappings or a specific mapping for the container
docker container prune Remove all stopped containers
docker container rename Rename a container
docker container restart Restart one or more containers
docker container rm Remove one or more containers
docker container run Run a command in a new container
docker container start Start one or more stopped containers
docker container stats Display a live stream of container(s) resource usage statistics
docker container stop Stop one or more running containers
docker container top Display the running processes of a container
docker container unpause Unpause all processes within one or more containers
docker container update Update configuration of one or more containers
docker container wait Block until one or more containers stop, then print their exit codes

Extended description

List the containers in the local repository. By default this shows only the running containers.

Filters

Filter output based on these conditions: - exited= an exit code of - label= or label== - status=(created|restarting|running|paused|exited|dead) - name= a container's name - id= a container's ID - is-task=(true|false) - containers that are a task (part of a service managed by swarm) - before=(|) - since=(|) - ancestor=([:tag]||<image@digest>) - containers created from an image or a descendant. - volume=(|) - network=(|) - containers connected to the provided network - health=(starting|healthy|unhealthy|none) - filters containers based on healthcheck status

Format

Pretty-print containers using a Go template. Valid placeholders: .ID - Container ID .Image - Image ID .Command - Quoted command .CreatedAt - Time when the container was created. .RunningFor - Elapsed time since the container was started. .Ports - Exposed ports. .Status - Container status. .Size - Container disk size. .Names - Container names. .Labels - All labels assigned to the container. .Label - Value of a specific label for this container. For example {{.Label "com.docker.swarm.cpu"}} .Mounts - Names of the volumes mounted in this container.

EXAMPLES

# Display all containers, including non-running

# docker container ls -a
CONTAINER ID        IMAGE                 COMMAND                CREATED             STATUS      PORTS    NAMES
a87ecb4f327c        fedora:20             /bin/sh -c #(nop) MA   20 minutes ago      Exit 0               desperate_brattain
01946d9d34d8        vpavlin/rhel7:latest  /bin/sh -c #(nop) MA   33 minutes ago      Exit 0               thirsty_bell
c1d3b0166030        acffc0358b9e          /bin/sh -c yum -y up   2 weeks ago         Exit 1               determined_torvalds
41d50ecd2f57        fedora:20             /bin/sh -c #(nop) MA   2 weeks ago         Exit 0               drunk_pike

Display only IDs of all containers, including non-running

# docker container ls -a -q
a87ecb4f327c
01946d9d34d8
c1d3b0166030
41d50ecd2f57

Display only IDs of all containers that have the name determined_torvalds

# docker container ls -a -q --filter=name=determined_torvalds
c1d3b0166030

Display containers with their commands

# docker container ls --format "{{.ID}}: {{.Command}}"
a87ecb4f327c: /bin/sh -c #(nop) MA
01946d9d34d8: /bin/sh -c #(nop) MA
c1d3b0166030: /bin/sh -c yum -y up
41d50ecd2f57: /bin/sh -c #(nop) MA

Display containers with their labels in a table

# docker container ls --format "table {{.ID}}\t{{.Labels}}"
CONTAINER ID        LABELS
a87ecb4f327c        com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd
01946d9d34d8
c1d3b0166030        com.docker.swarm.node=debian,com.docker.swarm.cpu=6
41d50ecd2f57        com.docker.swarm.node=fedora,com.docker.swarm.cpu=3,com.docker.swarm.storage=ssd

Display containers with their node label in a table

# docker container ls --format 'table {{.ID}}\t{{(.Label "com.docker.swarm.node")}}'
CONTAINER ID        NODE
a87ecb4f327c        ubuntu
01946d9d34d8
c1d3b0166030        debian
41d50ecd2f57        fedora

Display containers with remote-volume mounted

$ docker container ls --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}"
CONTAINER ID        MOUNTS
9c3527ed70ce        remote-volume

Display containers with a volume mounted in /data

$ docker container ls --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}"
CONTAINER ID        MOUNTS
9c3527ed70ce        remote-volume
chat icon Feedback? Suggestions? Can't find something in the docs?
Edit this page Request docs changes Get support
Rate this page: