Logrotate: Docker + nginx. Can't reload nginx container (logrotate: ALERT exited abnormally with [1])
Okay. Answering by myself.
-it
parameters can't be used with cron tasks (and logrotate is also a cron task).Because cron don't has interactive session (TTY).
I figured it out by running the /usr/bin/docker exec -it nginx-container-name nginx -s reopen > /dev/null 2>/dev/null
as a cron task. I have got error message "The input device is not a TTY"
So my new logrotate config looks like
/opt/docker_folders/logs/nginx/*.log { dateext daily rotate 31 nocreate missingok notifempty nocompress postrotate /usr/bin/docker exec nginx-container-name /bin/sh -c '/usr/sbin/nginx -s reopen > /dev/null 2>/dev/null' endscript su docker_nginx root}
And it's finally works.
I have to understand the parameter before using it
I have to understand the parameter before using it
I have to understand the parameter before using it