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 -a option.

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.

Use the 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.


Follow me on Twitter or connect on LinkedIn.

🚨 Want to make friends and learn from peers? You can join our free web developer community here. 🎉

DockerTerminal
Avatar for Niall Maher

Written by Niall Maher

Founder of Codú - The web developer community! I've worked in nearly every corner of technology businesses: Lead Developer, Software Architect, Product Manager, CTO, and now happily a Founder.

Loading

Fetching comments

Hey! 👋

Got something to say?

or to leave a comment.