How to Delete a Local Docker Container
A quick guide on how to delete a Docker container from the terminal.
List all Docker containers
Let's first start by listing all our containers. This will help us identify which one we want to remove and the data we need.
You can do this using the
docker ps command.
To see all containers, not just the active ones, use the
docker ps -a
This will give you a list of all containers and some information about them. The first column is the container ID, which you'll need for the next steps.
Stop the Docker container
To delete a container, it cannot be running.
docker stop command followed by the container ID to stop a container.
docker stop <container-id>
I hope it's obvious, but just for clarity, replace
<container-id> with your container's ID.
Remove the Docker container
Now, once your container is stopped, you can remove it! Run the
docker rm command followed by your container ID.
docker rm <container-id>
Since I often need to remember to delete my Containers and had to yet again Google recently, here's a guide for you and future forgetful me.
🚨 Want to make friends and learn from peers? You can join our free web developer community here. 🎉