Skip to content
DevOps AI ToolKit
Newsletter
All prompts
Docker with AI Difficulty: Intermediate ClaudeChatGPTCursor

Logging Driver & Log-Rotation Design Prompt

Design a Docker logging strategy: pick the right log driver, enforce json-file rotation so logs never fill the disk, and ship container logs to a central aggregator.

Target user
DevOps and SRE engineers managing container fleets
Difficulty
Intermediate
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior observability engineer who designs container logging so logs are durable, searchable, and can never fill a host disk.

I will provide some or all of:
- The current `/etc/docker/daemon.json` (or a note that logging is at defaults)
- `docker info | grep -i logging` output
- The per-service logging config from docker-compose.yml (`logging:` blocks)
- Where logs need to end up (local only, ELK/Loki/CloudWatch/Splunk, or "not decided")
- The workload profile: log volume per container, whether apps log to stdout/stderr or to files, and retention/compliance requirements

Your job:

1. **Assess the current state** — identify the active log driver, whether rotation is configured, and the concrete disk-fill risk from the default unbounded `json-file` driver. Explain how a chatty container fills `/var/lib/docker` on its own.
2. **Choose the driver** — recommend the appropriate driver for the goal: `json-file` with rotation for local + `docker logs` access, `local` for lower-overhead local storage, or a shipping driver (`fluentd`, `awslogs`, `gelf`, `journald`) for centralization — and explain the trade-off that non-json drivers may break `docker logs`.
3. **Set rotation** — give the exact `max-size`/`max-file` values as a daemon-wide default in `daemon.json`, and note that this applies only to newly created containers (existing ones keep their old config).
4. **Handle shipping reliability** — if centralizing, address buffering/back-pressure (e.g. `fluentd-async`, delivery mode) so a down log backend cannot block or crash containers, and recommend keeping a local fallback where the driver allows.
5. **Fix the app side** — confirm apps log to stdout/stderr (12-factor) rather than to files inside the container, and flag any that write to files needing a sidecar or volume-tail approach.
6. **Provide the config** — output the corrected `daemon.json`, the equivalent per-service Compose `logging:` block, the restart/rollout step, and a verification that rotation and shipping work.

Output as: (a) current-state assessment with disk-fill risk, (b) recommended driver + rationale, (c) daemon.json with rotation, (d) shipping/reliability config if centralizing, (e) app-side logging fixes, (f) rollout + verification steps.

Call out explicitly that changing the daemon default does not retroactively cap already-running containers, and give the command to check an existing container's effective log config.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Docker with AI prompts & error guides

Browse every Docker with AI prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.