Menu Close

Docker – How to remove containers in docker

Here, we will help you to understand how to remove containers in docker. We use “docker rm container_name” command to remove container.

docker rmcommand can be used with various options to remove containers in docker.


docker container rm [OPTIONS] CONTAINER [CONTAINER…]


--force , -fForce the removal of a running container (uses SIGKILL)
--link , -lRemove the specified link
--volumes , -vRemove anonymous volumes associated with the container


[email protected] ~ % docker ps

CONTAINER ID   IMAGE                    COMMAND                  CREATED          STATUS          PORTS                     NAMES

1486e1dfde13   redis:latest             "docker-entrypoint.s…"   30 seconds ago   Up 29 seconds>6379/tcp   redis-AEJ4

9ffc5b61103b   docker/getting-started   "/docker-entrypoint.…"   37 seconds ago   Up 36 seconds>80/tcp        beautiful_mccarthy

Delete the redis container (Showing in the above docker ps command)

[email protected] ~ % docker stop redis-AEJ4

[email protected] ~ % docker rm redis-AEJ4

[email protected] ~ % docker ps

CONTAINER ID   IMAGE                    COMMAND                  CREATED         STATUS         PORTS                NAMES

9ffc5b61103b   docker/getting-started   "/docker-entrypoint.…"   3 minutes ago   Up 3 minutes>80/tcp   beautiful_mccarthy

>>>>> Here, redis container is not running.

*** Before deleting the container, Make sure It's in stopped state. You can't delete running container.

To learn more about golang, Please refer given below link:


Posted in docker

Leave a Reply

Your email address will not be published. Required fields are marked *