Back to commands

Hosting Operations

Read-only, can be slow

Show Containers in a Clean Triage Table

You need a fast view of container state, image, uptime, and published ports without wrapped columns hiding the important parts.

Command

docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}\t{{.Ports}}'

Before you run this

System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.

When not to use it: Do not treat it as an application health check; it reports Docker state, not whether the app works.

Expected output

A table with container names, statuses, images, and port mappings.

System impact

Read-only, can be slow. Nothing changes. Docker prints container metadata in a narrower table.

Scope this to the smallest useful path or service on busy systems.

Recovery / rollback: no state is changed.

When to use it

Use during first-response container triage to see what is running, stopped, restarting, or exposing ports.

When not to use it

Do not treat it as an application health check; it reports Docker state, not whether the app works.

Watch this command run

Command transcript

This sanitized transcript shows the commands and output shape without exposing host details.

demo@lab:~$

$ docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}\t{{.Ports}}'

NAMES     STATUS                         IMAGE                         PORTS
web       Up 2 hours (healthy)           nginx:1.27                    0.0.0.0:8080->80/tcp
api       Restarting (1) 18 seconds ago  registry.example/api:v1.9.4   0.0.0.0:9000->9000/tcp
worker    Exited (0) 3 hours ago         registry.example/worker:v1.9.4

$ docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'

NAMES  STATUS                PORTS
web    Up 2 hours (healthy)  0.0.0.0:8080->80/tcp
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}\t{{.Ports}}'
  2. docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'

next steps

Related commands

Web Server Rescue Can be slow

Find Restarting Containers Fast

Restart loops hide in plain sight unless you filter for them.

docker ps -a --filter status=restarting --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}'
Hosting Operations Read-only

Snapshot Container CPU and Memory

Get Docker resource usage once, without leaving a live dashboard running.

docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}'
Hosting Operations Read-only

Check Container Health Status

Docker may say a container is running while its health check says otherwise.

docker inspect --format '{{.Name}} health={{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}} status={{.State.Status}}' web
Hosting Operations Read-only

See Container Network Attachments

A container can be healthy and still attached to the wrong network.

docker inspect --format '{{.Name}} {{range $name, $net := .NetworkSettings.Networks}}{{$name}} {{$net.IPAddress}} {{end}}' api
Hosting Operations Read-only

Summarize Docker Disk Usage

See how Docker storage is split across images, containers, volumes, and cache.

docker system df -v
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lfcs:operations-deployment
  • lfcs:services-logs
  • risk:read-only

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.