How to remove stopped and unused container in Docker.

Date: 06-02-2021

Step 01: List all Docker containers using the command.
# docker ps -a
OR
# docker container ls -a

Step 02: Enter the below command to stop the specific container.
# docker container stop [Container_id]
Note: [Container_id] – Numeric ID of the container from your list.
Use below command to stop all running container.
# docker container stop $(docker container ls -a)

Step 03: Use the below command to remove a stopped container.
# docker container rm [Container_id]
To remove all stopped and unused containers:
# docker container rm $(docker container ls -a)
OR
# docker system prune

Thank you!

Leave a Reply

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny