Lesson 6 / 26
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.
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 + removeQuick check: Which command shows containers that have already stopped?
- docker ps
- docker ps -a
- docker images
Answer
docker ps -a — Plain `docker ps` only shows running containers; `-a` includes stopped ones too.