github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/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  ## Description
    31  
    32  Removes all stopped containers.
    33  
    34  ## Examples
    35  
    36  ### Prune containers
    37  
    38  ```bash
    39  $ docker container prune
    40  WARNING! This will remove all stopped containers.
    41  Are you sure you want to continue? [y/N] y
    42  Deleted Containers:
    43  4a7f7eebae0f63178aff7eb0aa39cd3f0627a203ab2df258c1a00b456cf20063
    44  f98f9c2aa1eaf727e4ec9c0283bc7d4aa4762fbdba7f26191f26c97f64090360
    45  
    46  Total reclaimed space: 212 B
    47  ```
    48  
    49  ### Filtering
    50  
    51  The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
    52  than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
    53  
    54  The currently supported filters are:
    55  
    56  * until (`<timestamp>`) - only remove containers created before given timestamp
    57  
    58  The `until` filter can be Unix timestamps, date formatted
    59  timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed
    60  relative to the daemon machine’s time. Supported formats for date
    61  formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`,
    62  `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local
    63  timezone on the daemon will be used if you do not provide either a `Z` or a
    64  `+-00:00` timezone offset at the end of the timestamp.  When providing Unix
    65  timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
    66  that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
    67  seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
    68  fraction of a second no more than nine digits long.
    69  
    70  The following removes containers created more than 5 minutes ago:
    71  
    72  ```bash
    73  {% raw %}
    74  $ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
    75  
    76  CONTAINER ID        IMAGE               COMMAND             CREATED AT                      STATUS
    77  61b9efa71024        busybox             "sh"                2017-01-04 13:23:33 -0800 PST   Exited (0) 41 seconds ago
    78  53a9bc23a516        busybox             "sh"                2017-01-04 13:11:59 -0800 PST   Exited (0) 12 minutes ago
    79  
    80  $ docker container prune --force --filter "until=5m"
    81  
    82  Deleted Containers:
    83  53a9bc23a5168b6caa2bfbefddf1b30f93c7ad57f3dec271fd32707497cb9369
    84  
    85  Total reclaimed space: 25 B
    86  
    87  $ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
    88  
    89  CONTAINER ID        IMAGE               COMMAND             CREATED AT                      STATUS
    90  61b9efa71024        busybox             "sh"                2017-01-04 13:23:33 -0800 PST   Exited (0) 44 seconds ago
    91  {% endraw %}
    92  ```
    93  
    94  The following removes containers created before `2017-01-04T13:10:00`:
    95  
    96  ```bash
    97  {% raw %}
    98  $ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
    99  
   100  CONTAINER ID        IMAGE               COMMAND             CREATED AT                      STATUS
   101  53a9bc23a516        busybox             "sh"                2017-01-04 13:11:59 -0800 PST   Exited (0) 7 minutes ago
   102  4a75091a6d61        busybox             "sh"                2017-01-04 13:09:53 -0800 PST   Exited (0) 9 minutes ago
   103  
   104  $ docker container prune --force --filter "until=2017-01-04T13:10:00"
   105  
   106  Deleted Containers:
   107  4a75091a6d618526fcd8b33ccd6e5928ca2a64415466f768a6180004b0c72c6c
   108  
   109  Total reclaimed space: 27 B
   110  
   111  $ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
   112  
   113  CONTAINER ID        IMAGE               COMMAND             CREATED AT                      STATUS
   114  53a9bc23a516        busybox             "sh"                2017-01-04 13:11:59 -0800 PST   Exited (0) 9 minutes ago
   115  {% endraw %}
   116  ```
   117  
   118  ## Related commands
   119  
   120  * [system df](system_df.md)
   121  * [volume prune](volume_prune.md)
   122  * [image prune](image_prune.md)
   123  * [network prune](network_prune.md)
   124  * [system prune](system_prune.md)