github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/docs/reference/commandline/container_prune.md (about)

     1  ---
     2  title: "container prune"
     3  description: "Remove all stopped containers"
     4  keywords: container, prune, delete, remove
     5  ---
     6  
     7  <!-- This file is maintained within the docker/docker Github
     8       repository at https://github.com/docker/docker/. Make all
     9       pull requests against that repo. If you see this file in
    10       another repository, consider it read-only there, as it will
    11       periodically be overwritten by the definitive file. Pull
    12       requests which include edits to this file in other repositories
    13       will be rejected.
    14  -->
    15  
    16  # container prune
    17  
    18  ```markdown
    19  Usage:	docker container prune [OPTIONS]
    20  
    21  Remove all stopped containers
    22  
    23  Options:
    24  Options:
    25        --filter filter   Provide filter values (e.g. 'until=<timestamp>')
    26    -f, --force           Do not prompt for confirmation
    27        --help            Print usage
    28  ```
    29  
    30  ## Examples
    31  
    32  ```bash
    33  $ docker container prune
    34  WARNING! This will remove all stopped containers.
    35  Are you sure you want to continue? [y/N] y
    36  Deleted Containers:
    37  4a7f7eebae0f63178aff7eb0aa39cd3f0627a203ab2df258c1a00b456cf20063
    38  f98f9c2aa1eaf727e4ec9c0283bc7d4aa4762fbdba7f26191f26c97f64090360
    39  
    40  Total reclaimed space: 212 B
    41  ```
    42  
    43  ## Filtering
    44  
    45  The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
    46  than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
    47  
    48  The currently supported filters are:
    49  
    50  * until (`<timestamp>`) - only remove containers created before given timestamp
    51  
    52  The `until` filter can be Unix timestamps, date formatted
    53  timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed
    54  relative to the daemon machine’s time. Supported formats for date
    55  formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`,
    56  `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local
    57  timezone on the daemon will be used if you do not provide either a `Z` or a
    58  `+-00:00` timezone offset at the end of the timestamp.  When providing Unix
    59  timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
    60  that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
    61  seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
    62  fraction of a second no more than nine digits long.
    63  
    64  The following removes containers created more than 5 minutes ago:
    65  ```bash
    66  $ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
    67  CONTAINER ID        IMAGE               COMMAND             CREATED AT                      STATUS
    68  61b9efa71024        busybox             "sh"                2017-01-04 13:23:33 -0800 PST   Exited (0) 41 seconds ago
    69  53a9bc23a516        busybox             "sh"                2017-01-04 13:11:59 -0800 PST   Exited (0) 12 minutes ago
    70  
    71  $ docker container prune --force --filter "until=5m"
    72  Deleted Containers:
    73  53a9bc23a5168b6caa2bfbefddf1b30f93c7ad57f3dec271fd32707497cb9369
    74  
    75  Total reclaimed space: 25 B
    76  
    77  $ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
    78  CONTAINER ID        IMAGE               COMMAND             CREATED AT                      STATUS
    79  61b9efa71024        busybox             "sh"                2017-01-04 13:23:33 -0800 PST   Exited (0) 44 seconds ago
    80  ```
    81  
    82  The following removes containers created before `2017-01-04T13:10:00`:
    83  ```bash
    84  $ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
    85  CONTAINER ID        IMAGE               COMMAND             CREATED AT                      STATUS
    86  53a9bc23a516        busybox             "sh"                2017-01-04 13:11:59 -0800 PST   Exited (0) 7 minutes ago
    87  4a75091a6d61        busybox             "sh"                2017-01-04 13:09:53 -0800 PST   Exited (0) 9 minutes ago
    88  
    89  $ docker container prune --force --filter "until=2017-01-04T13:10:00"
    90  Deleted Containers:
    91  4a75091a6d618526fcd8b33ccd6e5928ca2a64415466f768a6180004b0c72c6c
    92  
    93  Total reclaimed space: 27 B
    94  
    95  $ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
    96  CONTAINER ID        IMAGE               COMMAND             CREATED AT                      STATUS
    97  53a9bc23a516        busybox             "sh"                2017-01-04 13:11:59 -0800 PST   Exited (0) 9 minutes ago
    98  ```
    99  
   100  ## Related information
   101  
   102  * [system df](system_df.md)
   103  * [volume prune](volume_prune.md)
   104  * [image prune](image_prune.md)
   105  * [network prune](network_prune.md)
   106  * [system prune](system_prune.md)