--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-worldThe broker-loss lesson leaves it off so stopped brokers can be restarted with docker start.Related terms
- docker run — Creates a new container from an image and starts it, in one step.
- docker rm — Deletes a stopped container and its writable layer; the image stays.
- ephemeral — Temporary: made to be thrown away, with nothing kept afterwards.
- docker start — Starts a container that already exists, keeping its writable layer and settings.
Taught in
- Why Containers: Bare Metal, Machines And Processes — Docker Architecture & Production Containers
- Namespaces And Cgroups: Isolation And Limits — Docker Architecture & Production Containers
- Install Docker And Verify Your Environment — Docker Architecture & Production Containers
- Run, Stop, Restart And Remove A Container — Docker Architecture & Production Containers
- Build Context, Dockerignore And Your First Dockerfile — Docker Architecture & Production Containers
- FROM, WORKDIR, COPY And ADD — Docker Architecture & Production Containers
- RUN, SHELL And Efficient Layer Caching — Docker Architecture & Production Containers
- ARG, ENV, LABEL, EXPOSE And VOLUME — Docker Architecture & Production Containers
- CMD, ENTRYPOINT, USER And Process Signals — Docker Architecture & Production Containers
- Multi Stage Builds, Targets And Build Secrets — Docker Architecture & Production Containers
- Tags, Digests And Reproducible Image References — Docker Architecture & Production Containers
- Authenticate, Tag, Push And Pull From A Registry — Docker Architecture & Production Containers
- Minimal Bases, Non Root Users And Smaller Images — Docker Architecture & Production Containers
- Scan, Patch And Inspect The Software Supply Chain — Docker Architecture & Production Containers
- Bind Mounts, Permissions And Backups — Docker Architecture & Production Containers
- Bridge Networks, DNS And Container Communication — Docker Architecture & Production Containers
- Environment, Secret Files And Runtime Restrictions — Docker Architecture & Production Containers
- Health Checks, Dependencies And Reliable Startup — Docker Architecture & Production Containers
- Development Overrides, Hot Reloading And Debuggers — Docker Architecture & Production Containers
- Integration Tests, Test Data And Compose Cleanup — Docker Architecture & Production Containers
- Diagnose Crashes, Resource Limits And Unhealthy Containers — Docker Architecture & Production Containers
- Harden And Deliver The Complete Service Stack — Docker Architecture & Production Containers
- Why A Log And Not A Queue — Apache Kafka & Event Streaming
- Losing A Broker — Apache Kafka & Event Streaming