How To Delete a Docker Container At Exit

In this blog post, we will learn how to delete a Docker container after exiting the container.

RM

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