List both running and stopped containers.
Which command is appropriate?
docker ps -a includes all containers. Without -a, docker ps normally shows only running containers.
Detailed explanation
docker psIncorrect. Plain docker ps normally lists only running containers.
docker images -aIncorrect. docker images -a lists images, not containers.
docker exec --allIncorrect. docker exec does not list containers.
docker ps -aCorrect. docker ps -a includes stopped containers.
Try it yourself
An example you can run in a temporary verification environment.
docker ps --help 2>/dev/null | grep -E -- '--all|-a' || trueExpected result
Dockerがある場合は--allのhelp。daemonへ一覧要求しないKey points
- docker ps
- -a
- Container state
Notes
- Environment: Docker CLI helpのみ
- Use a disposable VM or container when validating lifecycle commands.
- Exact command output can vary slightly by distribution and runtime version.
Foundation review
Identify the layer
An image listing and a container listing expose different object types; the state filter changes which containers appear.
Check the side effect
Use the ID and state columns to confirm which stopped object is safe to restart or remove.