You cannot remove a running container 🐳 Docker

Error response from daemon: You cannot remove a running container. Stop the container before attempting removal or force remove

docker rm refuses to delete a container that is still running.

Seen on: Docker

Meaning

Stop it first, or use docker rm -f to stop and remove in one step. For Compose projects, docker compose down stops and removes everything.

Common causes

  • Container still running
  • Restart policy brought it back up after stop

⚡ Quick fix

  1. docker stop c && docker rm c
  2. docker rm -f c
  3. docker compose down for Compose projects

Detailed fix by platform

Docker

  1. bash
    docker rm -f web
    docker compose down

How to diagnose

  1. State — docker ps | grep web
  2. Restart policy — docker inspect -f '{{.HostConfig.RestartPolicy.Name}}' web

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.