0
0
Dockerdevops~20 mins

Listing containers (docker ps, docker ps -a) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Container Listing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Output of docker ps command
You run docker ps on a system with three containers: one running, two stopped. What will docker ps show?
Docker
docker ps
ALists only the running container with its details
BLists all three containers with their details
CLists only the stopped containers
DShows an error because some containers are stopped
Attempts:
2 left
💡 Hint
Remember, docker ps shows only running containers by default.
💻 Command Output
intermediate
1:30remaining
Output of docker ps -a command
You run docker ps -a on a system with two running and two stopped containers. What will the command output include?
Docker
docker ps -a
ALists only the two running containers
BLists all four containers with their status
CLists only the two stopped containers
DShows an error because of invalid option
Attempts:
2 left
💡 Hint
The -a option means 'all' containers.
Troubleshoot
advanced
2:00remaining
Why does docker ps show no containers?
You run docker ps but it shows no containers, even though you know containers exist on the system. What is the most likely reason?
Docker
docker ps
AYou need to run <code>docker ps -a</code> to see containers
BYou do not have permission to list containers
CDocker daemon is not running
DNo containers are currently running
Attempts:
2 left
💡 Hint
Think about what docker ps shows by default.
Best Practice
advanced
1:30remaining
Best command to list all containers including stopped ones
Which command should you use to see all containers, including those that have stopped?
Adocker container ls
Bdocker ps
Cdocker ps -a
Ddocker container ls -q
Attempts:
2 left
💡 Hint
The -a option means 'all'.
🧠 Conceptual
expert
2:30remaining
Understanding container listing filters
You want to list only containers that exited with a non-zero status. Which command will do this?
Adocker ps -a --filter "exited=1"
Bdocker ps -a --filter "exited!=0"
Cdocker ps -a --filter "exited=0"
Ddocker ps -a --filter "status=exited"
Attempts:
2 left
💡 Hint
The filter 'exited' takes an exit code number.