DEV Community

Dev888 AUGUST
Dev888 AUGUST

Posted on

Managing Docker Containers: docker ps, stop and remove 🐳

In the last post, we ran our very first container with docker run hello-world.

But how do we see which containers are running? And how do we manage them?

That’s where docker ps comes in.


πŸ‘€ List containers with docker ps

Run:

docker ps
Enter fullscreen mode Exit fullscreen mode


`

This shows all running containers.
You’ll see columns like:

  • CONTAINER ID β†’ unique ID for the container
  • IMAGE β†’ which image it came from
  • STATUS β†’ running time
  • PORTS β†’ which ports are exposed
  • NAMES β†’ an auto-generated (or custom) name

πŸ“œ Show all containers (including stopped)

By default, docker ps only shows running containers.
To see all, use:

bash
docker ps -a

This will list containers that have already exited too.


πŸ›‘ Stop a container

If you want to stop a running container:

bash
docker stop <container_id_or_name>

Example:

bash
docker stop funny_panda


❌ Remove a container

Stopped containers still take up space.
To remove them:

bash
docker rm <container_id_or_name>

Example:

bash
docker rm funny_panda


🧹 Clean up all stopped containers

To remove all stopped containers at once:

bash
docker container prune

Docker will ask for confirmation before deleting.


πŸš€ Summary

  • docker ps β†’ list running containers
  • docker ps -a β†’ list all containers (running + stopped)
  • docker stop β†’ stop a container
  • docker rm β†’ remove a container
  • docker container prune β†’ clean up everything stopped

πŸ’‘ Next: we’ll explore Docker Images β€” how to list, pull, and remove them.

Follow me on Threads/Instagram for more Docker explained simply 🐳

`

Top comments (0)