Sign inSign up

samuelrunggaldier/logrotate

By samuelrunggaldier

•Updated about 1 month ago

Docker image for rotating log files from other containers

Image
Web servers
Operating systems
Monitoring & observability
2

50K+

samuelrunggaldier/logrotate repository overview

Docker Logrotate Logo

⁠Docker Logrotate

A lightweight Docker image that performs log rotation for other containers running in the same Docker environment.

Build and Publish Docker Image

⁠📦 Available Tags

Choose the right version for your environment:

  • latest: Latest stable build (updated monthly) - recommended for testing
  • 1.2.3: Specific version (from git tag v1.2.3) - recommended for production
  • 1.2: Latest patch version of a specific minor version - for controlled updates
  • 1: Latest minor.patch version of a specific major version - for automatic updates

Example: samuelrunggaldier/logrotate:1.2.3

⁠🔄 Overview

This container runs logrotate to manage log files from other containers in your Docker environment. It helps prevent log files from growing too large and consuming all available disk space.

⁠✨ Features

  • Rotates log files from other containers
  • Configurable rotation interval (hourly, daily, weekly, monthly, yearly)
  • Configurable size-based rotation
  • Configurable number of backup copies to keep
  • Timezone support
  • Automatic compression of rotated logs

⁠🚀 Quick Start

version: '3.8'

services:
  # Example service that generates logs
  app:
    image: your-app-image
    volumes:
      - logs:/logs

  # Logrotate service
  logrotate:
    image: samuelrunggaldier/logrotate:latest
    volumes:
      - logs:/logs
    environment:
      TZ: "Europe/Berlin"
      LOGS_PATH: "/logs/*.log"
      TRIGGER_INTERVAL: daily
      MAX_SIZE: 100M
      MAX_AGE: 30
      MAX_BACKUPS: 30
      DELAYCOMPRESS: "true"

volumes:
  logs:
    driver: local
⁠Run on Docker Desktop

Run locally with Docker Desktop using Docker Compose:

docker compose up -d
docker compose logs -f logrotate

Notes:

  • The sample uses a named volume logs that works out-of-the-box on Docker Desktop.
  • To use a bind mount instead, replace logs:/logs with ./logs:/logs and ensure the folder is in a file-shared location (Docker Desktop Settings → Resources → File sharing).

⁠⚙️ Environment Variables

VariableDescriptionDefaultOptions
LOGS_PATHPath to log files to rotate/logs/*.logAny valid path pattern
TRIGGER_INTERVALHow often to rotate logsdailyhourly, daily, weekly, monthly, yearly
MAX_SIZERotate if log file size reaches this thresholdNONENONE or size (e.g., 1K, 10M, 1G)
MAX_AGERemove rotated logs older than N days365NONE or days (e.g., 7, 30, 365)
MAX_BACKUPSNumber of backup copies to keep365Any positive integer
DELAYCOMPRESSDelay compression of rotated logs until next rotationtruetrue, false
TZTimezoneUTCAny valid timezone (e.g., Europe/Berlin)
SU_USERUser for logrotate su directive (helps with bind mounts on Docker Desktop)rootAny existing user inside container
SU_GROUPGroup for logrotate su directiverootAny existing group inside container

⁠📄 License

This project is licensed under the MIT License.

Tag summary

Content type

Image

Digest

sha256:9f546937e…

Size

5.9 MB

Last updated

about 1 month ago

docker pull samuelrunggaldier/logrotate