logrotate

linkyard/logrotate Docker Image

基于Alpine Linux的Docker容器,集成logrotate工具用于日志轮转管理,支持自定义轮转规则、压缩策略及调度周期。

2 次收藏下载次数: 0状态:社区镜像维护者:linkyard仓库类型:镜像最近更新:
下载命令
点击查看

logrotate

This is a docker container based on Alpine Linux with logrotate.

Configuration

Simply mount a directory with your logs into the container at /logs and optionally configure some logrotation features with the following environment variables:

  • LOGROTATE_FILE_PATTERN (default: *.log): File pattern within the /logs directory for logs to be rotated by logrotate
  • LOGROTATE_TRUNCATE (default: copytruncate): Truncation behaviour of logrotate, use either copytruncate or nocopytruncate
  • LOGROTATE_COMPRESS (default: nocompress): Compression behaviour for rotated files, use either nocompress or compress
  • LOGROTATE_ROTATE (default: 5): The rotate option of logrotate
  • LOGROTATE_SIZE (default 50M): the size option of logrotate

If you want to use a different logrotate configuration, mount a logrotate.conf at /etc/logrotate.conf into the container. The environment variables mentioned above have no effect if you supply your own logrotate configuration file.

By default, logrotate is run periodically every 15 minutes. You can override the cron schedule with the environment variable LOGROTATE_CRON. Use one of Alpine Linux' predefined periods (15min, hourly, daily, weekly or monthly) or specify a cron schedule expression like 5 4 * * * (at 04:05 every day). If you are unsure about the cron schedule expression syntax, consult a tool like crontab guru.

Examples

bash
docker run \
  -v /path/to/my/logs:/logs \
  -e LOGROTATE_FILE_PATTERN="*.log" \
  # don't rotate at all but truncate logs when they exceed the configured rotation size
  -e LOGROTATE_ROTATE="0" \
  # run logrotate every 5 minutes
  -e LOGROTATE_CRON="*/5 0 0 0 0" \
  linkyard:logrotate

Attribution

This image is somewhat similar to the no longer maintained https://github.com/blacklabelops/logrotate but a lot simpler to use and maintain.

Usage

It's double published (github and private gcr repo).

docker run ghcr.io/linkyard/logrotate or docker run eu.gcr.io/linkyard-191615/linkyard-cloud/logrotate

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 logrotate 镜像标签

docker pull docker.xuanyuan.run/linkyard/logrotate:<标签>

DockerHub 原生拉取命令

docker pull linkyard/logrotate:<标签>
专业版 · 高速稳定拉取镜像
50GB 仅 ¥8/年
高速镜像下载在线技术支持专业版保障服务可用付费会员免广告