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.

Watch this command run

Command transcript

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

demo@lab:~$

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

NAME    CPU %     MEM USAGE / LIMIT     NET I/O        BLOCK I/O
web     0.12%     42.1MiB / 512MiB      1.2MB / 880kB  4.1MB / 0B
api     8.40%     180.4MiB / 512MiB     3.8MB / 1.1MB  18MB / 2MB

$ docker stats --no-stream web

CONTAINER ID   NAME  CPU %  MEM USAGE / LIMIT
abc123         web   0.12%  42.1MiB / 512MiB
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

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

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
Hosting Operations Read-only

Find a Discarded Commit in Reflog

A reset does not mean the commit vanished.

cd /lab/git-recovery-rollback && git reflog --date=iso --format='%h %gd %gs' -6
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.