Remove Docker Container

Remove Docker Container

During the testing or development process, we can create many containers which are not used later. Unused Docker containers takes a disk space and can be removed. This tutorial demonstrates how to do that.

Remove container

To remove container by its ID or name, use docker rm command or docker container command with rm argument. For example, to remove a container named redis, you can use:

docker rm redis
docker container rm redis

Force to remove container

By default, cannot to remove container that is running. The -f option can be used to force the removal of a running container.

docker rm -f redis
docker container rm -f redis

Remove multiple containers

There is a way to remove multiple containers at a time by specifying ID or name of the containers.

docker rm redis nginx
docker container rm redis nginx

Remove container and its volumes

The -v option allows removing container and anonymous volumes associated with it. Note that, volume which was specified with a name, will not be removed.

docker rm -v redis
docker container rm -v redis

Leave a Comment

Cancel reply

Your email address will not be published.