You've just SSH'd into a server you've never worked on. Your only instruction from the outgoing engineer was _"a batch job failed on this box last night, can you figure out which one and why?"_ — and that's it. No runbook, no dashboard access. All you have is a shell and the docker CLI.
Your job: enumerate everything Docker knows about on this host, find the container that represents the failed job, and read its logs to surface the error message.
Five containers exist on the host — three are running (a web server, a database, a cache), one is a successfully-completed batch job that exited cleanly last week, and one is a batch job from last night that failed. By default, docker ps will only show you the three running ones. You need a flag to see the rest.
$ docker ps
CONTAINER ID IMAGE STATUS NAMES
a1b2c3d4e5f6 nginx:alpine Up 2 hours web-server
b2c3d4e5f6a1 postgres:15 Up 1 day db-postgres
c3d4e5f6a1b2 redis:7-alpine Up 3 days cache-redis
Only three containers? The outgoing engineer said a job failed — nothing here looks failed. That's because docker ps without a flag hides anything that isn't currently running.
You've solved it when:
docker CLI only.docker ps -a shows you every container, but on a busy host that can be 100+ rows. What filter flags would narrow it down to just exited non-zero or just the last hour?docker logs without flags streams the entire log. How would you read only the last 20 lines or only lines from the last 5 minutes?