github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/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  # rm
     8  
     9  ```markdown
    10  Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]
    11  
    12  Remove one or more containers
    13  
    14  Options:
    15    -f, --force     Force the removal of a running container (uses SIGKILL)
    16        --help      Print usage
    17    -l, --link      Remove the specified link
    18    -v, --volumes   Remove anonymous volumes associated with the container
    19  ```
    20  
    21  ## Examples
    22  
    23  ### Remove a container
    24  
    25  This removes the container referenced under the link `/redis`.
    26  
    27  ```bash
    28  $ docker rm /redis
    29  
    30  /redis
    31  ```
    32  
    33  ### Remove a link specified with `--link` on the default bridge network
    34  
    35  This removes the underlying link between `/webapp` and the `/redis`
    36  containers on the default bridge network, removing all network communication
    37  between the two containers. This does not apply when `--link` is used with
    38  user-specified networks.
    39  
    40  ```bash
    41  $ docker rm --link /webapp/redis
    42  
    43  /webapp/redis
    44  ```
    45  
    46  ### Force-remove a running container
    47  
    48  This command force-removes a running container.
    49  
    50  ```bash
    51  $ docker rm --force redis
    52  
    53  redis
    54  ```
    55  
    56  The main process inside the container referenced under the link `redis` will receive
    57  `SIGKILL`, then the container will be removed.
    58  
    59  ### Remove all stopped containers
    60  
    61  ```bash
    62  $ docker rm $(docker ps -a -q)
    63  ```
    64  
    65  This command deletes all stopped containers. The command
    66  `docker ps -a -q` above returns all existing container IDs and passes them to
    67  the `rm` command which deletes them. Running containers are not deleted.
    68  
    69  ### Remove a container and its volumes
    70  
    71  ```bash
    72  $ docker rm -v redis
    73  redis
    74  ```
    75  
    76  This command removes the container and any volumes associated with it.
    77  Note that if a volume was specified with a name, it will not be removed.
    78  
    79  ### Remove a container and selectively remove volumes
    80  
    81  ```bash
    82  $ docker create -v awesome:/foo -v /bar --name hello redis
    83  hello
    84  
    85  $ docker rm -v hello
    86  ```
    87  
    88  In this example, the volume for `/foo` remains intact, but the volume for
    89  `/bar` is removed. The same behavior holds for volumes inherited with
    90  `--volumes-from`.