github.com/jingleWang/moby@v1.13.1/man/docker-ps.1.md (about)

     1  % DOCKER(1) Docker User Manuals
     2  % Docker Community
     3  % FEBRUARY 2015
     4  # NAME
     5  docker-ps - List containers
     6  
     7  # SYNOPSIS
     8  **docker ps**
     9  [**-a**|**--all**]
    10  [**-f**|**--filter**[=*[]*]]
    11  [**--format**=*"TEMPLATE"*]
    12  [**--help**]
    13  [**-l**|**--latest**]
    14  [**-n**[=*-1*]]
    15  [**--no-trunc**]
    16  [**-q**|**--quiet**]
    17  [**-s**|**--size**]
    18  
    19  # DESCRIPTION
    20  
    21  List the containers in the local repository. By default this shows only
    22  the running containers.
    23  
    24  # OPTIONS
    25  **-a**, **--all**=*true*|*false*
    26     Show all containers. Only running containers are shown by default. The default is *false*.
    27  
    28  **-f**, **--filter**=[]
    29     Filter output based on these conditions:
    30     - exited=<int> an exit code of <int>
    31     - label=<key> or label=<key>=<value>
    32     - status=(created|restarting|running|paused|exited|dead)
    33     - name=<string> a container's name
    34     - id=<ID> a container's ID
    35     - is-task=(true|false) - containers that are a task (part of a service managed by swarm)
    36     - before=(<container-name>|<container-id>)
    37     - since=(<container-name>|<container-id>)
    38     - ancestor=(<image-name>[:tag]|<image-id>|<image@digest>) - containers created from an image or a descendant.
    39     - volume=(<volume-name>|<mount-point-destination>)
    40     - network=(<network-name>|<network-id>) - containers connected to the provided network
    41     - health=(starting|healthy|unhealthy|none) - filters containers based on healthcheck status
    42  
    43  **--format**="*TEMPLATE*"
    44     Pretty-print containers using a Go template.
    45     Valid placeholders:
    46        .ID - Container ID
    47        .Image - Image ID
    48        .Command - Quoted command
    49        .CreatedAt - Time when the container was created.
    50        .RunningFor - Elapsed time since the container was started.
    51        .Ports - Exposed ports.
    52        .Status - Container status.
    53        .Size - Container disk size.
    54        .Names - Container names.
    55        .Labels - All labels assigned to the container.
    56        .Label - Value of a specific label for this container. For example `{{.Label "com.docker.swarm.cpu"}}`
    57        .Mounts - Names of the volumes mounted in this container.
    58  
    59  **--help**
    60    Print usage statement
    61  
    62  **-l**, **--latest**=*true*|*false*
    63     Show only the latest created container (includes all states). The default is *false*.
    64  
    65  **-n**=*-1*
    66     Show n last created containers (includes all states).
    67  
    68  **--no-trunc**=*true*|*false*
    69     Don't truncate output. The default is *false*.
    70  
    71  **-q**, **--quiet**=*true*|*false*
    72     Only display numeric IDs. The default is *false*.
    73  
    74  **-s**, **--size**=*true*|*false*
    75     Display total file sizes. The default is *false*.
    76  
    77  # EXAMPLES
    78  # Display all containers, including non-running
    79  
    80      # docker ps -a
    81      CONTAINER ID        IMAGE                 COMMAND                CREATED             STATUS      PORTS    NAMES
    82      a87ecb4f327c        fedora:20             /bin/sh -c #(nop) MA   20 minutes ago      Exit 0               desperate_brattain
    83      01946d9d34d8        vpavlin/rhel7:latest  /bin/sh -c #(nop) MA   33 minutes ago      Exit 0               thirsty_bell
    84      c1d3b0166030        acffc0358b9e          /bin/sh -c yum -y up   2 weeks ago         Exit 1               determined_torvalds
    85      41d50ecd2f57        fedora:20             /bin/sh -c #(nop) MA   2 weeks ago         Exit 0               drunk_pike
    86  
    87  # Display only IDs of all containers, including non-running
    88  
    89      # docker ps -a -q
    90      a87ecb4f327c
    91      01946d9d34d8
    92      c1d3b0166030
    93      41d50ecd2f57
    94  
    95  # Display only IDs of all containers that have the name `determined_torvalds`
    96  
    97      # docker ps -a -q --filter=name=determined_torvalds
    98      c1d3b0166030
    99  
   100  # Display containers with their commands
   101  
   102      # docker ps --format "{{.ID}}: {{.Command}}"
   103      a87ecb4f327c: /bin/sh -c #(nop) MA
   104      01946d9d34d8: /bin/sh -c #(nop) MA
   105      c1d3b0166030: /bin/sh -c yum -y up
   106      41d50ecd2f57: /bin/sh -c #(nop) MA
   107  
   108  # Display containers with their labels in a table
   109  
   110      # docker ps --format "table {{.ID}}\t{{.Labels}}"
   111      CONTAINER ID        LABELS
   112      a87ecb4f327c        com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd
   113      01946d9d34d8
   114      c1d3b0166030        com.docker.swarm.node=debian,com.docker.swarm.cpu=6
   115      41d50ecd2f57        com.docker.swarm.node=fedora,com.docker.swarm.cpu=3,com.docker.swarm.storage=ssd
   116  
   117  # Display containers with their node label in a table
   118  
   119      # docker ps --format 'table {{.ID}}\t{{(.Label "com.docker.swarm.node")}}'
   120      CONTAINER ID        NODE
   121      a87ecb4f327c        ubuntu
   122      01946d9d34d8
   123      c1d3b0166030        debian
   124      41d50ecd2f57        fedora
   125  
   126  # Display containers with `remote-volume` mounted
   127  
   128      $ docker ps --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}"
   129      CONTAINER ID        MOUNTS
   130      9c3527ed70ce        remote-volume
   131  
   132  # Display containers with a volume mounted in `/data`
   133  
   134      $ docker ps --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}"
   135      CONTAINER ID        MOUNTS
   136      9c3527ed70ce        remote-volume
   137  
   138  # HISTORY
   139  April 2014, Originally compiled by William Henry (whenry at redhat dot com)
   140  based on docker.com source material and internal work.
   141  June 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>
   142  August 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>
   143  November 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>
   144  February 2015, updated by André Martins <martins@noironetworks.com>
   145  October 2016, updated by Josh Horwitz <horwitzja@gmail.com>