github.com/slene/docker@v1.8.0-rc1/docs/reference/commandline/ps.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "ps"
     4  description = "The ps command description and usage"
     5  keywords = ["container, running, list"]
     6  [menu.main]
     7  parent = "smn_cli"
     8  weight=1
     9  +++
    10  <![end-metadata]-->
    11  
    12  # ps
    13  
    14      Usage: docker ps [OPTIONS]
    15  
    16      List containers
    17  
    18        -a, --all=false       Show all containers (default shows just running)
    19        --before=""           Show only container created before Id or Name
    20        -f, --filter=[]       Filter output based on conditions provided
    21        -l, --latest=false    Show the latest created container, include non-running
    22        -n=-1                 Show n last created containers, include non-running
    23        --no-trunc=false      Don't truncate output
    24        -q, --quiet=false     Only display numeric IDs
    25        -s, --size=false      Display total file sizes
    26        --since=""            Show created since Id or Name, include non-running
    27        --format=[]       Pretty-print containers using a Go template
    28  
    29  Running `docker ps --no-trunc` showing 2 linked containers.
    30  
    31      $ docker ps
    32      CONTAINER ID        IMAGE                        COMMAND                CREATED              STATUS              PORTS               NAMES
    33      4c01db0b339c        ubuntu:12.04                 bash                   17 seconds ago       Up 16 seconds       3300-3310/tcp       webapp
    34      d7886598dbe2        crosbymichael/redis:latest   /redis-server --dir    33 minutes ago       Up 33 minutes       6379/tcp            redis,webapp/db
    35  
    36  `docker ps` will show only running containers by default. To see all containers:
    37  `docker ps -a`
    38  
    39  `docker ps` will group exposed ports into a single range if possible. E.g., a container that exposes TCP ports `100, 101, 102` will display `100-102/tcp` in the `PORTS` column.
    40  
    41  ## Filtering
    42  
    43  The filtering flag (`-f` or `--filter)` format is a `key=value` pair. If there is more
    44  than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`)
    45  
    46  The currently supported filters are:
    47  
    48  * id (container's id)
    49  * label (`label=<key>` or `label=<key>=<value>`)
    50  * name (container's name)
    51  * exited (int - the code of exited containers. Only useful with `--all`)
    52  * status (created|restarting|running|paused|exited)
    53  
    54  ## Successfully exited containers
    55  
    56      $ docker ps -a --filter 'exited=0'
    57      CONTAINER ID        IMAGE             COMMAND                CREATED             STATUS                   PORTS                      NAMES
    58      ea09c3c82f6e        registry:latest   /srv/run.sh            2 weeks ago         Exited (0) 2 weeks ago   127.0.0.1:5000->5000/tcp   desperate_leakey
    59      106ea823fe4e        fedora:latest     /bin/sh -c 'bash -l'   2 weeks ago         Exited (0) 2 weeks ago                              determined_albattani
    60      48ee228c9464        fedora:20         bash                   2 weeks ago         Exited (0) 2 weeks ago                              tender_torvalds
    61  
    62  This shows all the containers that have exited with status of '0'
    63  
    64  ## Formatting
    65  
    66  The formatting option (`--format`) will pretty-print container output using a Go template.
    67  
    68  Valid placeholders for the Go template are listed below:
    69  
    70  Placeholder | Description
    71  ---- | ----
    72  `.ID` | Container ID
    73  `.Image` | Image ID
    74  `.Command` | Quoted command
    75  `.CreatedAt` | Time when the container was created.
    76  `.RunningFor` | Elapsed time since the container was started.
    77  `.Ports` | Exposed ports.
    78  `.Status` | Container status.
    79  `.Size` | Container disk size.
    80  `.Labels` | All labels asigned to the container.
    81  `.Label` | Value of a specific label for this container. For example `{{.Label "com.docker.swarm.cpu"}}`
    82  
    83  When using the `--format` option, the `ps` command will either output the data exactly as the template
    84  declares or, when using the `table` directive, will include column headers as well.
    85  
    86  The following example uses a template without headers and outputs the `ID` and `Command`
    87  entries separated by a colon for all running containers:
    88  
    89      $ docker ps --format "{{.ID}}: {{.Command}}"
    90      a87ecb4f327c: /bin/sh -c #(nop) MA
    91      01946d9d34d8: /bin/sh -c #(nop) MA
    92      c1d3b0166030: /bin/sh -c yum -y up
    93      41d50ecd2f57: /bin/sh -c #(nop) MA
    94  
    95  To list all running containers with their labels in a table format you can use:
    96  
    97      $ docker ps --format "table {{.ID}}\t{{.Labels}}"
    98      CONTAINER ID        LABELS
    99      a87ecb4f327c        com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd
   100      01946d9d34d8
   101      c1d3b0166030        com.docker.swarm.node=debian,com.docker.swarm.cpu=6
   102      41d50ecd2f57        com.docker.swarm.node=fedora,com.docker.swarm.cpu=3,com.docker.swarm.storage=ssd