Back to commands

Hosting Operations

Read-only

Snapshot Container CPU and Memory

You need a quick CPU and memory snapshot for running containers.

Command

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

Before you run this

System impact: Read-only. Low when scoped to the shown target.

When not to use it: Do not treat one snapshot as a trend; repeat it or use monitoring for longer windows.

Expected output

A table showing container CPU percentage, memory usage, network I/O, and block I/O.

System impact

Read-only. Nothing changes. Docker reads current resource counters.

Recovery / rollback: no state is changed.

When to use it

Use when a host is slow, memory pressure is suspected, or one container may be noisy.

When not to use it

Do not treat one snapshot as a trend; repeat it or use monitoring for longer windows.

next steps

Related commands

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 Can be slow

Show Containers in a Clean Triage Table

Turn noisy docker ps output into the few fields operators scan first.

docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}\t{{.Ports}}'
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 style performance-task practice

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