Tips > Ops & Security

Configure Log Rotation to Prevent Disk Fill

Docker's default `json-file` logging driver stores container logs with no size limit.

Docker's default json-file logging driver stores container logs with no size limit. On a busy n8n instance with verbose execution logging, container logs can consume tens of gigabytes within weeks, silently filling the disk until the host becomes unresponsive. Setting max-size and max-file at the container level caps log storage with automatic rotation.

Real-world example: You limit each container to 3 log files of 50 MB each, capping total log storage at 150 MB per container.

services:
  n8n:
    image: n8nio/n8n:1.94.1
    restart: unless-stopped
    logging:
      driver: json-file
      options:
        max-size: "50m"
        max-file: "3"
        tag: "n8n"

  postgres:
    image: postgres:16-alpine
    restart: unless-stopped
    logging:
      driver: json-file
      options:
        max-size: "20m"
        max-file: "3"
        tag: "postgres"
```text
Alternatively, set the default for all containers in the Docker daemon configuration:

```json title="/etc/docker/daemon.json"
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "50m",
    "max-file": "3"
  }
}
```text
```bash

# Apply the daemon configuration change

sudo systemctl restart docker
```text
> **Warning: Existing Containers**
>
> Changing `daemon.json` only affects newly created containers. Existing containers keep their original logging configuration. You must recreate them with `docker compose up -d --force-recreate` to pick up the new defaults.

This prevents a common silent failure where the disk fills up, causing PostgreSQL to crash, n8n to lose data, and the host to become unreachable via SSH.

**Related:** [Set a Unique Encryption Key and Back It Up](../security-best-practices/01-set-a-unique-encryption-key-and-back-it-up.md) | [Configure Payload Size and Binary Data Mode for Large Files](../performance-and-large-files/01-configure-payload-size-and-binary-data-mode-for-large-files.md)

Showcase builds

19 complete workflows from my own projects, each with its n8n workflow JSON to import. Showcase entries link the file at the end of the article.

See the showcase builds

Keep reading

191 entries grouped by topic, from first workflow to queue mode. Free, no signup.

Browse the encyclopedia

Need it built?

I design, build and run n8n systems for clients. Every engagement starts with a $1,500 diagnostic audit, credited toward the build.

Book a 20-minute call