# Container Lifecycle — Docker

Source: https://www.geekswithgeeks.com/en/docker/docker-container-lifecycle

> List, stop, and remove containers as they move through their lifecycle.

## ps, stop, rm

`ps` lists running containers (`-a` for all, including stopped). `stop` sends a graceful shutdown; `rm` deletes the container.

```bash
docker ps            # running containers
docker ps -a         # all containers, incl. stopped
docker stop <id>     # graceful stop
docker rm <id>       # remove a stopped container
docker rm -f <id>    # force stop + remove
```

**Quiz:** Which command shows containers that have already stopped?

- [ ] docker ps
- [x] docker ps -a
- [ ] docker images

*Answer:* docker ps -a. Plain `docker ps` only shows running containers; `-a` includes stopped ones too.
