Back to commands

Web Server Rescue

Read-only, can be slow

Find Restarting Containers Fast

A service is unstable and you need to quickly identify containers stuck restarting.

Command

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

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 stop at this command; follow with recent logs for the failing container.

Expected output

A table of restarting containers, or no rows if none match.

System impact

Read-only, can be slow. Nothing changes. Docker filters container metadata to restarting containers.

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

Recovery / rollback: no state is changed.

When to use it

Use when an app is unavailable, flapping, or repeatedly failing startup checks.

When not to use it

Do not stop at this command; follow with recent logs for the failing container.

Watch this command run

Command transcript

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

demo@lab:~$

$ docker ps -a --filter status=restarting --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}'

NAMES     STATUS                         IMAGE
api       Restarting (1) 18 seconds ago  registry.example/api:v1.9.4

$ docker logs --tail 40 api

api: loading config
api: ERROR database connection refused
api: exiting with code 1
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. docker ps -a --filter status=restarting --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}'
  2. docker logs --tail 40 api

next steps

Related commands

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}}'
Web Server Rescue Read-only

Show Published Container Ports

When a service is unreachable, confirm Docker is publishing the port you think it is.

docker port web
Web Server Rescue State change

Read Recent Container Logs

Skip the million-line log scroll and read only the recent failure window.

docker logs --since 10m --tail 100 api
Web Server Rescue Can be slow

Find Large Directories with du

Once you know a filesystem is full, the next question is where.

du -xh --max-depth=1 /var 2>/dev/null | sort -h
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:networking
  • 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.