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
-
Multi-Container Log Aggregation Design Prompt
Design a log aggregation approach for a multi-container host or Compose stack, choosing logging drivers, structured formats, and a shipping path to a central store while preventing disk exhaustion.
-
Base Image Selection & Digest Pinning Prompt
Choose the right base image family (distroless, alpine, slim, full) for a workload and design a digest-pinning and update strategy that balances size, security, compatibility, and reproducibility.
-
Docker Build Context Reduction & .dockerignore Audit Prompt
Audit a bloated Docker build context, identify what is being uploaded to the daemon unnecessarily, and produce a tuned .dockerignore plus COPY strategy that shrinks context and speeds builds.
-
BuildKit Cache Mount Strategy Design Prompt
Design a BuildKit cache-mount and cache-export strategy that speeds up dependency installs and compilation across local and CI builds without shipping cache into the final image.
More Docker with AI prompts & error guides
Browse every Docker with AI prompt and troubleshooting guide in one place.
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.