mirror of https://github.com/docker/cli.git
docs: move --rm to docker run reference
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
parent
32189ca273
commit
f98444490f
|
@ -95,7 +95,7 @@ Create and run a new container from an image
|
||||||
| `-q`, `--quiet` | | | Suppress the pull output |
|
| `-q`, `--quiet` | | | Suppress the pull output |
|
||||||
| [`--read-only`](#read-only) | | | Mount the container's root filesystem as read only |
|
| [`--read-only`](#read-only) | | | Mount the container's root filesystem as read only |
|
||||||
| [`--restart`](#restart) | `string` | `no` | Restart policy to apply when a container exits |
|
| [`--restart`](#restart) | `string` | `no` | Restart policy to apply when a container exits |
|
||||||
| `--rm` | | | Automatically remove the container when it exits |
|
| [`--rm`](#rm) | | | Automatically remove the container when it exits |
|
||||||
| `--runtime` | `string` | | Runtime to use for this container |
|
| `--runtime` | `string` | | Runtime to use for this container |
|
||||||
| [`--security-opt`](#security-opt) | `list` | | Security Options |
|
| [`--security-opt`](#security-opt) | `list` | | Security Options |
|
||||||
| `--shm-size` | `bytes` | `0` | Size of /dev/shm |
|
| `--shm-size` | `bytes` | `0` | Size of /dev/shm |
|
||||||
|
@ -1060,6 +1060,36 @@ $ docker inspect -f "{{ .State.StartedAt }}" my-container
|
||||||
Combining `--restart` (restart policy) with the `--rm` (clean up) flag results
|
Combining `--restart` (restart policy) with the `--rm` (clean up) flag results
|
||||||
in an error. On container restart, attached clients are disconnected.
|
in an error. On container restart, attached clients are disconnected.
|
||||||
|
|
||||||
|
### <a name="rm"></a> Clean up (--rm)
|
||||||
|
|
||||||
|
By default, a container's file system persists even after the container exits.
|
||||||
|
This makes debugging a lot easier, since you can inspect the container's final
|
||||||
|
state and you retain all your data.
|
||||||
|
|
||||||
|
If you are running short-term **foreground** processes, these container file
|
||||||
|
systems can start to pile up. If you'd like Docker to automatically clean up
|
||||||
|
the container and remove the file system when the container exits, use the
|
||||||
|
`--rm` flag:
|
||||||
|
|
||||||
|
```text
|
||||||
|
--rm=false: Automatically remove the container when it exits
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note**
|
||||||
|
>
|
||||||
|
> If you set the `--rm` flag, Docker also removes the anonymous volumes
|
||||||
|
> associated with the container when the container is removed. This is similar
|
||||||
|
> to running `docker rm -v my-container`. Only volumes that are specified without
|
||||||
|
> a name are removed. For example, when running:
|
||||||
|
>
|
||||||
|
> ```console
|
||||||
|
> $ docker run --rm -v /foo -v awesome:/bar busybox top
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> the volume for `/foo` will be removed, but the volume for `/bar` will not.
|
||||||
|
> Volumes inherited via `--volumes-from` will be removed with the same logic: if
|
||||||
|
> the original volume was specified with a name it will **not** be removed.
|
||||||
|
|
||||||
### <a name="add-host"></a> Add entries to container hosts file (--add-host)
|
### <a name="add-host"></a> Add entries to container hosts file (--add-host)
|
||||||
|
|
||||||
You can add other hosts into a container's `/etc/hosts` file by using one or
|
You can add other hosts into a container's `/etc/hosts` file by using one or
|
||||||
|
|
|
@ -241,33 +241,6 @@ $ echo $?
|
||||||
3
|
3
|
||||||
```
|
```
|
||||||
|
|
||||||
## Clean up (--rm)
|
|
||||||
|
|
||||||
By default a container's file system persists even after the container
|
|
||||||
exits. This makes debugging a lot easier (since you can inspect the
|
|
||||||
final state) and you retain all your data by default. But if you are
|
|
||||||
running short-term **foreground** processes, these container file
|
|
||||||
systems can really pile up. If instead you'd like Docker to
|
|
||||||
**automatically clean up the container and remove the file system when
|
|
||||||
the container exits**, you can add the `--rm` flag:
|
|
||||||
|
|
||||||
--rm=false: Automatically remove the container when it exits
|
|
||||||
|
|
||||||
> **Note**
|
|
||||||
>
|
|
||||||
> If you set the `--rm` flag, Docker also removes the anonymous volumes
|
|
||||||
> associated with the container when the container is removed. This is similar
|
|
||||||
> to running `docker rm -v my-container`. Only volumes that are specified without
|
|
||||||
> a name are removed. For example, when running:
|
|
||||||
>
|
|
||||||
> ```console
|
|
||||||
> $ docker run --rm -v /foo -v awesome:/bar busybox top
|
|
||||||
> ```
|
|
||||||
>
|
|
||||||
> the volume for `/foo` will be removed, but the volume for `/bar` will not.
|
|
||||||
> Volumes inherited via `--volumes-from` will be removed with the same logic: if
|
|
||||||
> the original volume was specified with a name it will **not** be removed.
|
|
||||||
|
|
||||||
## Security configuration
|
## Security configuration
|
||||||
|
|
||||||
| Option | Description |
|
| Option | Description |
|
||||||
|
|
Loading…
Reference in New Issue