Docker image for rotating log files from other containers
50K+
A lightweight Docker image that performs log rotation for other containers running in the same Docker environment.
Choose the right version for your environment:
latest: Latest stable build (updated monthly) - recommended for testing1.2.3: Specific version (from git tag v1.2.3) - recommended for production1.2: Latest patch version of a specific minor version - for controlled updates1: Latest minor.patch version of a specific major version - for automatic updatesExample: samuelrunggaldier/logrotate:1.2.3
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.
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 locally with Docker Desktop using Docker Compose:
docker compose up -d
docker compose logs -f logrotate
Notes:
logs that works out-of-the-box on Docker Desktop.logs:/logs with ./logs:/logs and ensure the folder is in a file-shared location (Docker Desktop Settings → Resources → File sharing).| Variable | Description | Default | Options |
|---|---|---|---|
LOGS_PATH | Path to log files to rotate | /logs/*.log | Any valid path pattern |
TRIGGER_INTERVAL | How often to rotate logs | daily | hourly, daily, weekly, monthly, yearly |
MAX_SIZE | Rotate if log file size reaches this threshold | NONE | NONE or size (e.g., 1K, 10M, 1G) |
MAX_AGE | Remove rotated logs older than N days | 365 | NONE or days (e.g., 7, 30, 365) |
MAX_BACKUPS | Number of backup copies to keep | 365 | Any positive integer |
DELAYCOMPRESS | Delay compression of rotated logs until next rotation | true | true, false |
TZ | Timezone | UTC | Any valid timezone (e.g., Europe/Berlin) |
SU_USER | User for logrotate su directive (helps with bind mounts on Docker Desktop) | root | Any existing user inside container |
SU_GROUP | Group for logrotate su directive | root | Any existing group inside container |
This project is licensed under the MIT License.
Content type
Image
Digest
sha256:9f546937e…
Size
5.9 MB
Last updated
about 1 month ago
docker pull samuelrunggaldier/logrotate