github.com/yogeshlonkar/moby@v1.13.2-0.20201203103638-c0b64beaea94/docs/reference/commandline/rm.md (about)

     1  ---
     2  title: "rm"
     3  description: "The rm command description and usage"
     4  keywords: "remove, Docker, container"
     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  # rm
    17  
    18  ```markdown
    19  Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]
    20  
    21  Remove one or more containers
    22  
    23  Options:
    24    -f, --force     Force the removal of a running container (uses SIGKILL)
    25        --help      Print usage
    26    -l, --link      Remove the specified link
    27    -v, --volumes   Remove the volumes associated with the container
    28  ```
    29  
    30  ## Examples
    31  
    32  ### Remove a container
    33  
    34  This will remove the container referenced under the link
    35  `/redis`.
    36  
    37  ```bash
    38  $ docker rm /redis
    39  
    40  /redis
    41  ```
    42  
    43  ### Remove a link specified with `--link` on the default bridge network
    44  
    45  This will remove the underlying link between `/webapp` and the `/redis`
    46  containers on the default bridge network, removing all network communication
    47  between the two containers. This does not apply when `--link` is used with
    48  user-specified networks.
    49  
    50  ```bash
    51  $ docker rm --link /webapp/redis
    52  
    53  /webapp/redis
    54  ```
    55  
    56  ### Force-remove a running container
    57  
    58  This command will force-remove a running container.
    59  
    60  ```bash
    61  $ docker rm --force redis
    62  
    63  redis
    64  ```
    65  
    66  The main process inside the container referenced under the link `redis` will receive
    67  `SIGKILL`, then the container will be removed.
    68  
    69  ### Remove all stopped containers
    70  
    71  ```bash
    72  $ docker rm $(docker ps -a -q)
    73  ```
    74  
    75  This command will delete all stopped containers. The command
    76  `docker ps -a -q` will return all existing container IDs and pass them to
    77  the `rm` command which will delete them. Any running containers will not be
    78  deleted.
    79  
    80  ### Remove a container and its volumes
    81  
    82  ```bash
    83  $ docker rm -v redis
    84  redis
    85  ```
    86  
    87  This command will remove the container and any volumes associated with it.
    88  Note that if a volume was specified with a name, it will not be removed.
    89  
    90  ### Remove a container and selectively remove volumes
    91  
    92  ```bash
    93  $ docker create -v awesome:/foo -v /bar --name hello redis
    94  hello
    95  $ docker rm -v hello
    96  ```
    97  
    98  In this example, the volume for `/foo` will remain intact, but the volume for
    99  `/bar` will be removed. The same behavior holds for volumes inherited with
   100  `--volumes-from`.