Skip to content

Commit 8c8e40d

Browse files
author
Steffen Bleul
authored
Merge pull request #13 from Shuliyey/feature/tzdata
Introduce tzdata, TZ environment variable will take effect (when tzdata is installed)
2 parents 42f10de + 85dcb52 commit 8c8e40d

2 files changed

Lines changed: 39 additions & 6 deletions

File tree

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ RUN export CONTAINER_USER=logrotate && \
1515
apk add --update \
1616
tar \
1717
gzip \
18-
wget && \
18+
wget \
19+
tzdata && \
1920
if [ "${LOGROTATE_VERSION}" = "latest" ]; \
2021
then apk add logrotate ; \
2122
else apk add "logrotate=${LOGROTATE_VERSION}" ; \

README.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ $ docker run -d \
5656
blacklabelops/logrotate
5757
~~~~
5858

59+
> This will logrotate any logfile(s) under /var/lib/docker/containers, /var/log/docker (or subdirectories of them).
60+
5961
# Customize Log File Ending
6062

6163
You can define the file endings fluentd will attach to. The container will by default crawl for
@@ -97,6 +99,8 @@ $ docker run -d \
9799
blacklabelops/logrotate
98100
~~~~
99101

102+
> This will logrotate logfile(s) on hourly basis.
103+
100104
# Set the Number of Rotations
101105

102106
The default number of rotations is five. Further rotations will delete old logfiles. You
@@ -135,6 +139,8 @@ $ docker run -d \
135139
blacklabelops/logrotate
136140
~~~~
137141

142+
> This will logrotate when logfile(s) reaches 10M+.
143+
138144
# Set Log File compression
139145

140146
The default logrotate setting is `nocompress`. In order to enable logfile compression
@@ -151,6 +157,8 @@ $ docker run -d \
151157
blacklabelops/logrotate
152158
~~~~
153159

160+
> This will compress the logrotated logs.
161+
154162
# Set the Output directory
155163

156164
By default, logrotate will rotate logs in their respective directories. You can
@@ -187,6 +195,8 @@ $ docker run -d \
187195
blacklabelops/logrotate
188196
~~~~
189197

198+
> This will logrotate on go-cron schedule \* \* \* \* \* \* (every second).
199+
190200
# Log and View the Logrotate Output
191201

192202
You can specify a logfile for the periodical logrotate execution. The file
@@ -206,7 +216,7 @@ $ docker run -d \
206216
blacklabelops/logrotate
207217
~~~~
208218

209-
> You will be able to see logrotate output every minute in file logs/logrotatecron.log
219+
> You will be able to see logrotate output every minute in file logs/logrotatecron.log.
210220
211221
# Logrotate Commandline Parameters
212222

@@ -270,12 +280,11 @@ $ docker run -d \
270280
blacklabelops/logrotate
271281
~~~~
272282

273-
> You will be able to see cron output every minute in file logs/cron.log
274-
283+
> You will be able to see cron output every minute in file logs/cron.log.
275284
276285
# Setting a Date Extension
277286

278-
With Logrotate it is possible to split files and name them by the date they were generated when used with `LOGROTATE_CRONSCHEDULE`. By setting `LOGROTATE_DATEFORMAT` you will enable the Logrotate `dateext` option.
287+
With Logrotate it is possible to split files and name them by the date they were generated when used with `LOGROTATE_DATEFORMAT`. By setting `LOGROTATE_DATEFORMAT` you will enable the Logrotate `dateext` option.
279288

280289
The default Logrotate format is `-%Y%m%d`, to enable the defaults `LOGROTATE_DATEFORMAT` should be set to this.
281290

@@ -292,6 +301,8 @@ $ docker run -d \
292301
blacklabelops/logrotate
293302
~~~~
294303

304+
> This will set logrotate to split files and name them by date format -%Y%m%d.
305+
295306
# Disable Auto Update
296307

297308
With Logrotate by default it auto update its logrotate configuration file to ensure it only captures all the intended log file in the `LOGS_DIRECTORIES` (before it rotates the log files). It is possible to disable auto update when used with `LOGROTATE_AUTOUPDATE`. By setting `LOGROTATE_AUTOUPDATE` (to not equal true) you will disable the auto update of Logrotate.
@@ -309,9 +320,30 @@ docker run -d \
309320
blacklabelops/logrotate
310321
~~~~
311322

323+
> This will disable logrotate configuration file update (when logrotate action is triggering).
324+
325+
# Set Time Zone
326+
327+
With Logrotate by default it logrotate logs in `UTC` time zone. It is possible to set time zone when used with `TZ`. By setting `TZ` (to a valid time zone) it will logrotate logs in the specified time zone.
328+
329+
The default `TZ` is `""`, to set to different time zone. E.g `Australia/Melbourne`.
330+
331+
Example:
332+
333+
~~~~
334+
docker run -d \
335+
-v /var/lib/docker/containers:/var/lib/docker/containers \
336+
-v /var/log/docker:/var/log/docker \
337+
-e "LOGS_DIRECTORIES=/var/lib/docker/containers /var/log/docker" \
338+
-e "TZ=Australia/Melbourne" \
339+
blacklabelops/logrotate
340+
~~~~
341+
342+
> This will logrotate in Australia/Melbourne time zone.
343+
312344
## Used in Kubernetes
313345

314-
When we run container in Kubernetes, we can use the logrotate container to rotate the logs. As we create
346+
When we run container in Kubernetes, we can use the logrotate container to rotate the logs. As we create
315347

316348
an DaemonSet in cluster ,we can deploy an logrotate container in every nodes of the cluster.
317349

0 commit comments

Comments
 (0)