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, so a busy n8n instance can fill the disk within weeks. Setting max-size and max-file at the container level caps log storage and rotates logs automatically. This prevents a silent failure where the disk fills and the host becomes unreachable.

Why do n8n container logs fill the disk?

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.

How do you configure log rotation?

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"

Alternatively, set the default for all containers in the Docker daemon configuration file /etc/docker/daemon.json:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "50m",
    "max-file": "3"
  }
}

Then apply the daemon configuration change by restarting Docker:


# Apply the daemon configuration change

sudo systemctl restart docker

What happens to existing containers?

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 · Configure Payload Size and Binary Data Mode for Large Files

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

190 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 an introductory call