Skip to content

Lightweight Docker image to be used in conjunction with a dockerized Traefik instance to rotate Traefik's access logs.

License

Notifications You must be signed in to change notification settings

vegardit/docker-traefik-logrotate

Repository files navigation

vegardit/traefik-logrotate

Build Status License Docker Pulls Docker Stars Contributor Covenant

  1. What is it?
  2. License

What is it?

Lightweight Docker image based on alpine:3 to be used in conjunction with a dockerized Traefik instance to rotate Traefik's access logs.

It is automatically built weekly to include the latest OS security fixes.

Usage

Example docker-compose.yml:

version: '3.8'

services:

  traefik:
    image: traefik:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /var/log/traefik:/var/log/traefik:rw # folder containing access.log file
    deploy:
      restart_policy:
        condition: on-failure
        delay: 5s
    # ... other configurations


  logrotate:
    image: vegardit/traefik-logrotate:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:rw # required to send USR1 signal to Traefik after log rotation
      - /var/log/traefik:/var/log/traefik:rw # folder containing access.log file
    environment:
      TZ: "Europe/Berlin"
      # all environment variables are optional and show the default values:
      LOGROTATE_LOGS: "/var/log/traefik/*.log" # log files to rotate, directory must match volume mount
      LOGROTATE_TRIGGER_INTERVAL: daily  # rotate daily, must be one of: daily, weekly, monthly, yearly
      LOGROTATE_TRIGGER_SIZE: 50M        # rotate if log file size reaches 50MB
      LOGROTATE_MAX_BACKUPS: 14          # keep 14 backup copies per rotated log file
      LOGROTATE_START_INDEX: 1           # first rotated file is called access.1.log
      LOGROTATE_FILE_MODE: 0644          # file mode of the rotated file
      LOGROTATE_FILE_USER: root          # owning user of the rotated file
      LOGROTATE_FILE_GROUP: root         # owning group of the rotated file
      CRON_SCHEDULE: "* * * * *"
      CRON_LOG_LEVEL: 8                  # see https://unix.stackexchange.com/a/414010/378036
      # command to determine the id of the container running Traefik:
      TRAEFIK_CONTAINER_ID_COMMAND: docker ps --no-trunc --quiet --filter label=org.opencontainers.image.title=Traefik
    deploy:
      restart_policy:
        condition: on-failure
        delay: 5s

License

All files in this repository are released under the Apache License 2.0.

Individual files contain the following tag instead of the full license text:

SPDX-License-Identifier: Apache-2.0

This enables machine processing of license information based on the SPDX License Identifiers that are available here: https://spdx.org/licenses/.

About

Lightweight Docker image to be used in conjunction with a dockerized Traefik instance to rotate Traefik's access logs.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published