blacklabelops / logrotate Goto Github PK
View Code? Open in Web Editor NEWDockerized Logrotate. Attach, Compress, Rotate!
Home Page: https://hub.docker.com/r/blacklabelops/logrotate/
License: MIT License
Dockerized Logrotate. Attach, Compress, Rotate!
Home Page: https://hub.docker.com/r/blacklabelops/logrotate/
License: MIT License
We'd love to be able to use a pinned version of logrotate - mostly so we don't run latest
- and a new release would be greatly appreciated :)
some apps need a signal before the close the file
how do we do that with this?
I'm using this in my docker-compose.yml:
logrotate:
image: "blacklabelops/logrotate"
volumes:
- /var/lib/docker/containers:/var/lib/docker/containers
environment:
- LOGS_DIRECTORIES=/var/lib/docker/containers
- LOGROTATE_INTERVAL=hourly
- LOGROTATE_COPIES=7
- LOGROTATE_SIZE=10M
- LOGROTATE_COMPRESSION=compress
I don't see any compression when it rotates.
The logs were also much bigger when I first ran it and it didn't split it up in files of max 10M size, it just moved the old file to .1
executing: /bin/bash -c /usr/bin/logrotate.d/update-logrotate.sh; /usr/sbin/logrotate --state=/logrotate-status/logrotate.status /usr/bin/logrotate.d/logrotate.conf
find: "/var/log/docker: No such file or directory
find: /var/log/nginx": No such file or directory
├── docker-compose.yml
└── logs
├── file.log
└── nginx
├── access.log
└── error.log
This is my docker-compose.yaml setup
---
version: '2.4'
services:
ssl:
image: nginx:latest
ports:
- 2020:80
volumes:
- ./logs/nginx:/var/log/nginx
logrotate:
image: blacklabelops/logrotate:1.3
environment:
- LOGS_DIRECTORIES="/var/log/docker /var/log/nginx"
- LOGROTATE_INTERVAL=hourly
- LOGROTATE_COMPRESSION=compress
- LOGROTATE_COPIES=30
- TZ=Asia/Singapore
- LOGROTATE_CRONSCHEDULE=* * * * * *
volumes:
- ./logs:/var/log/docker
- ./logs/nginx:/var/log/nginx
Any way to log rotate a subfolder of a volume?
I've tried:
volumes:
- /var/lib/docker/volumes/wp_docker_litespeed_lsws_sites/_data/localhost/wp_logs:/var/log/wp
and
LOGS_DIRECTORIES: "/var/lib/docker/containers /var/log/docker /var/lib/docker/volumes /var/log/wp"
I want to rotate log files right now with -e "LOGROTATE_PARAMETERS=f"
. But it's inoperative.
Hi is there some way to do a healthcheck when using blacklabelops/logrotate
?
The default logrotate_croninterval="1 0 0 0 * *"
(at
logrotate/docker-entrypoint.sh
Line 245 in fe817d4
LOGROTATE_CRONSCHEDULE
is not set. It results in no invocations of logrotate and the following error message:
2016/11/21 16:40:23 Beginning of range (0) below minimum (1): 0
The 4th (day of month) can not be 0, it must be in range 1-31.
I am unsure what the intended value is, but I think it must be at least hourly looking at the lowest possible logrotate interval. If this is the case a cron interval of 0 0 * * * *
would work. (every hour at 0 minutes and 0 seconds).
I am working around this by providing a valid LOGROTATE_CRONSCHEDULE
as environment var.
How would one go about sending a signal from one container process to another container process?
For nginx, the worker needs to be gracefully restarted to remove the file handle on the log files via something like:
postrotate
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
endscript
But, as a sidecar, how would you do this without exposing the docker control socket?
-L
option is missing in find
invocation in that script.
Hi,
I am trying to deploy log rotate in the K8s cluster as a sidecar container but getting permission denied error.
touch: /usr/bin/logrotate.d/logrotate.conf: Permission denied
Is it possible to run logrotate w/o root privileges?
I would like to setup this cool container to rotate syslog file, but it looks like it cannot be done with the envs provided, since the code assume you have files with extension, or am I missing something?
Support for logrotate parameters maxage and minsize.
Hi, one quick question, if a container dies/recreated with a new container ID, and the old one is deleted, e.g. by K8s, will the rotated logs expire after the expected date?
I guess not, since the config is updated to new containers. If this is true, is there a way to handle this?
Thanks!
I will stop supporting and implementing Docker images starting in early 2019.
Repositories will be transferred to blacklabelops-legacy and archived for read only purpose.
The following repositories and images are affected:
January 2019
March 2019
I have many log files present in /var/log/company_name
to be rotated on an hourly basis into /var/log/company_name/rotated
, keeping the past 24-hours. All logs seem to be rotating except a select few, which grow to gigabytes in size.
Upon inspecting the logrotate logs with docker logs logrotate
, it appears that all the logfiles that aren't rotating have the following message printed when processing:
Found new file /var/log/company_name/mysql_error.log, Processing...
File has unknown user or group: , user: UNKNOWN, group: video
However, logfiles that are properly rotated have the following message printed:
Found new file /var/log/company_name/wkhtmltopdf.gunicorn.log, Processing...
Inserting new /var/log/company_name/wkhtmltopdf.gunicorn.log to /usr/bin/logrotate.d/logrotate.conf
Other notes:
User: root
Logrotate version: 1.2
Logrotate hash: sha256:e0d5e50a8716d7859079df4849f9034c56d0cb38ed46ad118b87e41f8a9437d6
Capabilities: dac_override
, setgid
, setuid
Network: none
Environment:
LOGROTATE_INTERVAL=hourly
LOGS_DIRECTORIES=/var/log/company_name
LOGROTATE_OLDDIR=/var/log/company_name/rotated
LOGROTATE_LOGFILE=/var/log/company_name/logrotate.log
LOGROTATE_COPIES=24
LOGROTATE_COMPRESSION=compress
LOGROTATE_STATUSFILE=/company_name/logrotate_status/logrotate.status
LOGROTATE_PARAMETERS=vf
I also tried enabling all capabilities and the network without any luck.
The error message appear accurate when running an ls -lahS
on the log directory. But I don't understand why logrotate won't touch those files or how to force it to work with those files.
- name: LOGS_DIRECTORIES
value: "/var/lib/docker/containers /var/log/docker"
- name: LOGROTATE_INTERVAL
value: "hourly"
- name: LOGROTATE_OLDDIR
value: "/logs"
- name: LOGROTATE_SIZE
value: 2k
`
Hello, we would like to use * to match all potential candidates, the reason is our service might generate logs with timestamp as suffix. Thank you.
I have the fallowing docker compose that is launched within a docker swarm. The rotation interval is set to hourly, but the logs are rotated daily.
version: '3.3'
services:
log-roate:
image: blacklabelops/logrotate
environment:
- LOGS_DIRECTORIES=/var/lib/docker/containers
- LOGROTATE_COPIES=100
- LOGROTATE_COMPRESSION=compress
- LOGROTATE_INTERVAL=hourly
- LOGROTATE_DATEFORMAT=-%Y-%m-%d-%s
volumes:
- type: bind
source: /var/lib/docker/containers
target: /var/lib/docker/containers
deploy:
mode: global
Hello,
I'm trying to use the logrotate docker image. I am overriding the LOGROTATE_CRONSCHEDULE environment variable. However, it is not having an impact on the logrotate command. Can you take a look?
environment:
- "LOGS_DIRECTORIES=/home/logs"
- "LOGROTATE_CRONSCHEDULE=* * * * * *"
- "LOGROTATE_LOGFILE=/tmp/rotate-log"
- "LGROTATE_PARAMETERS=vf"
- "LOGROTATE_DATEFORMAT=-%Y-%m-%d-%s"
- "LOGROTATE_COPIES=5"
Hi
I'm not sure if this container is abandonware or not, but I just discovered and implemented it, and it seems perfect for me with one small exception.
I have all of my containers set to place all of their logs in a central location on the host (/mnt/e/logs
) and then a subdir per container.
In my case, it would be cleaner and more efficient to just mount the top-level dir as the volume mount, and then use an env var to ignore specific dirs (some containers have built in rotate mechanisms that I don't need this container to rotate for them).
Currently, I have to mount something like 20 containers, and also add them each on the single env var line, like this:
LOGS_DIRECTORIES: '/mnt/e/Docker/Logs/authelia /mnt/e/Docker/Logs/mysql /mnt/e/Docker/Logs/something /mnt/e/Docker/Logs/somethingelse' (etc., for another 15 or so more)
Having an env var something like:
LOGS_IGNORE_DIRECTORIES: '/mnt/e/Docker/Logs/ignorethisone /mnt/e/Docker/Logs/ignorethisonetoo'
Would be much nicer, because then I'd just mount the top-level dir, let logrotate recurse through all subdirs, and ignore just like, 3 directories. :)
Standard init linux error showed up. I updated entry point from #!/bin/bash to #!/bin/sh as it works for many people but it didn't work for me.
Any suggestion to solve it ?
Thanks for a great project. I have only a small (yet getting bigger) problem:
$ ls -lh
-rwxrw-rw- 1 root root 1.6K Dec 3 01:14 alternatives.log
drwxrw-rw- 2 root root 4.0K Dec 3 01:42 apt
drwxr-xr-x 2 root root 4.0K Nov 19 03:59 docker
-rwxrw-rw- 1 root root 527.4K Dec 9 05:15 docker.log
-rwxrw-rw- 1 root root 36.5M Dec 4 00:00 docker.log-20171204.gz
-rwxrw-rw- 1 root root 1.2M Dec 8 00:00 docker.log-20171208
-rwxrw-rw- 1 root root 59.4K Dec 3 01:42 dpkg.log
-rw-r--r-- 1 root root 510 Dec 3 01:42 fontconfig.log
-rwxrw-rw- 1 root root 314.0K Dec 9 05:15 lastlog
-rwxrw-rw- 1 root root 1.7G Dec 9 05:17 messages
-rwxrw-rw- 1 root root 663.5M Dec 9 05:17 secure
-rwxrw-rw- 1 root root 2.3G Dec 9 05:17 syslog
As you can see secure
, messages
and syslog
weren't touched by logrotate. Is it possible for you guys to have an option where we can add LOGS_FILES
?
The new image is Alpine Docker 1.9 conform. Dockerhub is still on Docker 1.8 build slaves. This ticket is to remind me to check builds.
Imagelayers also seems to have problems when Dockerhub builds fail.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.