Automatically remove the container after it exits.
Section: Containers
Run and remove on exit
bash
bash
docker run --rm alpine:latest echo helloExplanation
Ideal for short-lived commands and one-off jobs.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Containers