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.
Incorrect. Plain docker ps normally lists only running containers.
docker images -aIncorrect. docker images -a lists images, not containers.
Incorrect. docker images -a lists images, not containers.
docker exec --allIncorrect. docker exec does not list containers.
Incorrect. docker exec does not list containers.
docker ps -aCorrect. docker ps -a includes stopped containers.
Correct. 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のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.