Docker - Remove container using the docker run --rm command
by
Jeremy Canfield |
Updated: September 10 2022
| Docker articles
By default, when creating a container using the docker run command, the container will not be removed after the container has completed.
The --rm flag can be used to remove the container after it has completed.
In this example, a container is created using the https://hub.docker.com/repository/docker/jeremycanfield/my-hello-world-image image and the container will be removed after it has been completed.
Almost always, this is coupled with the --detach flag to run the container in the background.
[john.doe@docker ~]# docker run --detach --rm jeremycanfield/my-hello-world-image:latest
Did you find this article helpful?
If so, consider buying me a coffee over at