Solution Maintenance

Log Rotation

To setup rotating logs, add following lines in /etc/docker/daemon.json file (create the file if it doesn’t exist already) and restart the docker daemon using systemctl restart docker on all instances. In the following configuration, the maximum file size is kept to 20 MB for a maximum of 3 files.

"log-driver": "json-file",
"log-opts": {
   "max-size": "20m",  # Max size of the log files.  
   "max-file": "3"     # The maximum number of log files that can be present.

Verifying Logs

Logs for each container are available in files as well as within docker daemon. To see the logs for any container, execute docker ps and get the id of the container. Use that id to see the logs using docker logs container_id. At any given time, the active machine would be the one with highest keepalived priority, so the logs would be stored there.

Related articles