In this blog post, I will show you how to delete a Docker container after exiting the container.
The Docker CLI has a switch the allows us to simply delete the container after exit.
Below, you can see an example.
I am using the –rm command switch to spin a centos container that will be deleted at exit.
docker container run --rm -it centos /bin/sh