Rotate logs for docker containers

Document ID : KB000117778
Last Modified Date : 18/10/2018
Show Technical Document Details
Question:
The users would like to do rotate logs of the containers docker.
For example, one file by day.
actually :
only one file : 434f2de4e0877d28a1f6c9e36da953651c966d405381eb36284e029aab147c40-json.log

{"log":"MAC verified OK\n","stream":"stderr","time":"2018-09-21T14:15:15.152799419Z"}
{"log":"MAC verified OK\n","stream":"stderr","time":"2018-09-21T14:15:15.159411411Z"}
{"log":"MAC verified OK\n","stream":"stderr","time":"2018-09-21T14:15:15.164976812Z"}
{"log":"2018/09/21 14:15:15 [warn] 1#1: duplicate MIME type \"text/html\" in /etc/nginx/gzip.nginx:21\n","stream":"stderr","time":"2018-09-21T14:15:15.194723
794Z"}
{"log":"nginx: [warn] duplicate MIME type \"text/html\" in 
Environment:
ENV: Portal 9.2 
Answer:
You can put rotation configuration in this file : 
[root@YRFRLX197 nmon]# more /etc/logrotate.conf 
# see "man logrotate" for details 
# rotate log files weekly 
#weekly 
daily 

# keep 4 weeks worth of backlogs 
rotate 28 

# create new (empty) log files after rotating old ones 
create 

# use date as a suffix of the rotated file 
Dateext