Docker: Find & inspect containers
7 Docker commands: Find & inspect containers. Click a command to see what each part does.
Docker: Find & inspect containersIndex
- Whole sheet120
- Basics: images & containers11
- Volumes & networks4
- Find & inspect containers7
- Environment variables & container config12
- Software versions inside containers & images9
- Logs & shells5
- Run containers3
- Images4
- Cleanup6
- Docker Compose v27
- Container lifecycle & live changes10
- Builds, multi-platform & moving images11
- Volumes, networks & remote hosts in depth12
- Compose: more commands9
- Swarm mode10
Find & inspect containers7
docker ps -a | grep <container-id>Find a container by ID or name in the full listWhat each part does
docker pslist containers (running only by default)-a--all: include stopped / exited containers too|pipe the table into grepgrep <container-id>keep only the row that contains that ID (a prefix like 3f2a is enough) or name
Tip Built-in alternative without grep: docker ps -a --filter id=<container-id> (or --filter name=<name>).
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"Only running containers, compact tableWhat each part does
docker psrunning containers--format "table …"Go template output; "table" adds column headers{{.Names}} {{.Status}} {{.Ports}}fields to show; \t separates columns
docker ps -a --filter status=exited --filter name=<name>Filter containers by state, name or imageWhat each part does
-aall containers--filter status=exitedonly exited ones (also: running, paused, restarting…)--filter name=<name>name contains <name>. Repeating --filter combines them
docker ps -qJust the IDs (for scripting)What each part does
-q--quiet: print only container IDs, one per line
docker inspect --format '{{.State.ExitCode}} OOMKilled={{.State.OOMKilled}}' <container>Why did it stop? Exit code and OOMWhat each part does
docker inspect <container>full JSON details of the container--format '…'Go template: print only the fields you ask for{{.State.ExitCode}}0 = clean exit, 137 = killed (often out of memory), 143 = SIGTERM{{.State.OOMKilled}}true if the kernel killed it for exceeding its memory limit
docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}}' <container>Container IP addressWhat each part does
range .NetworkSettings.Networksloop over every network the container is attached to{{.IPAddress}}print its IP on that network
docker stats --no-streamLive CPU / memory per containerWhat each part does
docker statsresource usage of running containers--no-streamprint one snapshot and exit instead of refreshing
Nothing matches.
My DevOps Playbook by Angelo John Calleja