github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/man/src/container/ls.md (about)

     1  List the containers in the local repository. By default this shows only
     2  the running containers.
     3  
     4  ## Filters
     5  
     6  Filter output based on these conditions:
     7     - exited=<int> an exit code of <int>
     8     - label=<key> or label=<key>=<value>
     9     - status=(created|restarting|running|paused|exited|dead)
    10     - name=<string> a container's name
    11     - id=<ID> a container's ID
    12     - is-task=(true|false) - containers that are a task (part of a service managed by swarm)
    13     - before=(<container-name>|<container-id>)
    14     - since=(<container-name>|<container-id>)
    15     - ancestor=(<image-name>[:tag]|<image-id>|<image@digest>) - containers created from an image or a descendant.
    16     - volume=(<volume-name>|<mount-point-destination>)
    17     - network=(<network-name>|<network-id>) - containers connected to the provided network
    18     - health=(starting|healthy|unhealthy|none) - filters containers based on healthcheck status
    19  
    20  ## Format
    21  
    22     Pretty-print containers using a Go template.
    23     Valid placeholders:
    24        .ID - Container ID
    25        .Image - Image ID
    26        .Command - Quoted command
    27        .CreatedAt - Time when the container was created.
    28        .RunningFor - Elapsed time since the container was started.
    29        .Ports - Exposed ports.
    30        .Status - Container status.
    31        .Size - Container disk size.
    32        .Names - Container names.
    33        .Labels - All labels assigned to the container.
    34        .Label - Value of a specific label for this container. For example `{{.Label "com.docker.swarm.cpu"}}`
    35        .Mounts - Names of the volumes mounted in this container.
    36  
    37  # EXAMPLES
    38  # Display all containers, including non-running
    39  
    40      # docker container ls -a
    41      CONTAINER ID        IMAGE                 COMMAND                CREATED             STATUS      PORTS    NAMES
    42      a87ecb4f327c        fedora:20             /bin/sh -c #(nop) MA   20 minutes ago      Exit 0               desperate_brattain
    43      01946d9d34d8        vpavlin/rhel7:latest  /bin/sh -c #(nop) MA   33 minutes ago      Exit 0               thirsty_bell
    44      c1d3b0166030        acffc0358b9e          /bin/sh -c yum -y up   2 weeks ago         Exit 1               determined_torvalds
    45      41d50ecd2f57        fedora:20             /bin/sh -c #(nop) MA   2 weeks ago         Exit 0               drunk_pike
    46  
    47  # Display only IDs of all containers, including non-running
    48  
    49      # docker container ls -a -q
    50      a87ecb4f327c
    51      01946d9d34d8
    52      c1d3b0166030
    53      41d50ecd2f57
    54  
    55  # Display only IDs of all containers that have the name `determined_torvalds`
    56  
    57      # docker container ls -a -q --filter=name=determined_torvalds
    58      c1d3b0166030
    59  
    60  # Display containers with their commands
    61  
    62      # docker container ls --format "{{.ID}}: {{.Command}}"
    63      a87ecb4f327c: /bin/sh -c #(nop) MA
    64      01946d9d34d8: /bin/sh -c #(nop) MA
    65      c1d3b0166030: /bin/sh -c yum -y up
    66      41d50ecd2f57: /bin/sh -c #(nop) MA
    67  
    68  # Display containers with their labels in a table
    69  
    70      # docker container ls --format "table {{.ID}}\t{{.Labels}}"
    71      CONTAINER ID        LABELS
    72      a87ecb4f327c        com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd
    73      01946d9d34d8
    74      c1d3b0166030        com.docker.swarm.node=debian,com.docker.swarm.cpu=6
    75      41d50ecd2f57        com.docker.swarm.node=fedora,com.docker.swarm.cpu=3,com.docker.swarm.storage=ssd
    76  
    77  # Display containers with their node label in a table
    78  
    79      # docker container ls --format 'table {{.ID}}\t{{(.Label "com.docker.swarm.node")}}'
    80      CONTAINER ID        NODE
    81      a87ecb4f327c        ubuntu
    82      01946d9d34d8
    83      c1d3b0166030        debian
    84      41d50ecd2f57        fedora
    85  
    86  # Display containers with `remote-volume` mounted
    87  
    88      $ docker container ls --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}"
    89      CONTAINER ID        MOUNTS
    90      9c3527ed70ce        remote-volume
    91  
    92  # Display containers with a volume mounted in `/data`
    93  
    94      $ docker container ls --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}"
    95      CONTAINER ID        MOUNTS
    96      9c3527ed70ce        remote-volume