--rm

A docker run flag that deletes the container automatically as soon as it exits.

In more detail

Ideal for one-off commands and experiments: no stopped containers pile up. Anonymous volumes created for the container are removed too. Because the container is gone once it stops, it cannot be restarted and its logs cannot be read afterwards.

Examples

docker run --rm hello-world
The broker-loss lesson leaves it off so stopped brokers can be restarted with docker start.

Related terms

Taught in

References