-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathdocker-logs
27 lines (17 loc) · 1.07 KB
/
docker-logs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# https://www.youtube.com/watch?v=pDQzadfUfpE
docker run --log-opt max-size=20m --log-opt max-file=10 myapp:latest
# https://hub.docker.com/r/linkyard/logrotate
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
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