github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/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     - ancestor=(<image-name>[:tag]|<image-id>|<image@digest>)
     8       containers created from an image or a descendant.
     9     - before=(<container-name>|<container-id>)
    10     - expose=(<port>[/<proto>]|<startport-endport>/[<proto>])
    11     - exited=<int> an exit code of <int>
    12     - health=(starting|healthy|unhealthy|none)
    13     - id=<ID> a container's ID
    14     - isolation=(`default`|`process`|`hyperv`) (Windows daemon only)
    15     - is-task=(true|false)
    16     - label=<key> or label=<key>=<value>
    17     - name=<string> a container's name
    18     - network=(<network-id>|<network-name>)
    19     - publish=(<port>[/<proto>]|<startport-endport>/[<proto>])
    20     - since=(<container-name>|<container-id>)
    21     - status=(created|restarting|removing|running|paused|exited)
    22     - volume=(<volume name>|<mount point destination>)
    23  
    24  ## Format
    25  
    26  The formatting option (**--format**) pretty-prints container output
    27  using a Go template.
    28  
    29  Valid placeholders for the Go template are listed below:
    30     - .ID           - Container ID.
    31     - .Image        - Image ID.
    32     - .Command      - Quoted command.
    33     - .CreatedAt    - Time when the container was created.
    34     - .RunningFor   - Elapsed time since the container was started.
    35     - .Ports        - Exposed ports.
    36     - .Status       - Container status.
    37     - .Size         - Container disk size.
    38     - .Names        - Container names.
    39     - .Labels       - All labels assigned to the container.
    40     - .Label        - Value of a specific label for this container.
    41                       For example **'{{.Label "com.docker.swarm.cpu"}}'**.
    42     - .Mounts       - Names of the volumes mounted in this container.
    43     - .Networks     - Names of the networks attached to this container.
    44  
    45  # EXAMPLES
    46  
    47  ## Display all containers, including non-running
    48  
    49      $ docker container ls -a
    50      CONTAINER ID        IMAGE                 COMMAND                CREATED             STATUS      PORTS    NAMES
    51      a87ecb4f327c        fedora:20             /bin/sh -c #(nop) MA   20 minutes ago      Exit 0               desperate_brattain
    52      01946d9d34d8        vpavlin/rhel7:latest  /bin/sh -c #(nop) MA   33 minutes ago      Exit 0               thirsty_bell
    53      c1d3b0166030        acffc0358b9e          /bin/sh -c yum -y up   2 weeks ago         Exit 1               determined_torvalds
    54      41d50ecd2f57        fedora:20             /bin/sh -c #(nop) MA   2 weeks ago         Exit 0               drunk_pike
    55  
    56  ## Display only IDs of all containers, including non-running
    57  
    58      $ docker container ls -a -q
    59      a87ecb4f327c
    60      01946d9d34d8
    61      c1d3b0166030
    62      41d50ecd2f57
    63  
    64  ## Display only IDs of all containers that have the name `determined_torvalds`
    65  
    66      $ docker container ls -a -q --filter=name=determined_torvalds
    67      c1d3b0166030
    68  
    69  ## Display containers with their commands
    70  
    71      $ docker container ls --format "{{.ID}}: {{.Command}}"
    72      a87ecb4f327c: /bin/sh -c #(nop) MA
    73      01946d9d34d8: /bin/sh -c #(nop) MA
    74      c1d3b0166030: /bin/sh -c yum -y up
    75      41d50ecd2f57: /bin/sh -c #(nop) MA
    76  
    77  ## Display containers with their labels in a table
    78  
    79      $ docker container ls --format "table {{.ID}}\t{{.Labels}}"
    80      CONTAINER ID        LABELS
    81      a87ecb4f327c        com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd
    82      01946d9d34d8
    83      c1d3b0166030        com.docker.swarm.node=debian,com.docker.swarm.cpu=6
    84      41d50ecd2f57        com.docker.swarm.node=fedora,com.docker.swarm.cpu=3,com.docker.swarm.storage=ssd
    85  
    86  ## Display containers with their node label in a table
    87  
    88      $ docker container ls --format 'table {{.ID}}\t{{(.Label "com.docker.swarm.node")}}'
    89      CONTAINER ID        NODE
    90      a87ecb4f327c        ubuntu
    91      01946d9d34d8
    92      c1d3b0166030        debian
    93      41d50ecd2f57        fedora
    94  
    95  ## Display containers with `remote-volume` mounted
    96  
    97      $ docker container ls --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}"
    98      CONTAINER ID        MOUNTS
    99      9c3527ed70ce        remote-volume
   100  
   101  ## Display containers with a volume mounted in `/data`
   102  
   103      $ docker container ls --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}"
   104      CONTAINER ID        MOUNTS
   105      9c3527ed70ce        remote-volume
   106  
   107  ## Display containers that have published port of 80:
   108  
   109      $ docker ps --filter publish=80
   110      CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS                   NAMES
   111      fc7e477723b7        busybox             "top"               About a minute ago   Up About a minute   0.0.0.0:32768->80/tcp   admiring_roentgen
   112  
   113  ## Display containers that have exposed TCP port in the range of `8000-8080`:
   114  
   115      $ docker ps --filter expose=8000-8080/tcp
   116      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
   117      9833437217a5        busybox             "top"               21 seconds ago      Up 19 seconds       8080/tcp            dreamy_mccarthy