Log rotation for docker or limit log size?


Recommended Posts

53 minutes ago, jang430 said:

Does the log being full prevent my Docker apps from starting?  It's happening, Docker apps aren't opening, at least 1 closed.

 

Yes, this is possible. Docker log files are stored in the same file system as system logs. When full it will cause an issue for Docker.

 

Link to comment
9 minutes ago, aptalca said:

I thought docker log files were stored within the docker image

 

 

Both Docker and VM log files are in /var/log. These are the services.

 

Log files of the containers themselves are in the docker image.

Edited by bonienl
Link to comment

I clicked on the log on the upper right, a new window opens.  Even after a long time, nothing comes out anymore.  I decided to restart the whole Unraid machine.  After restart, log went down to 2%.  Docker apps are up and running once again.  

 

I hope the log doesn't go full once again.

Link to comment
 
Both Docker and VM log files are in /var/log. These are the services.
 
Log files of the containers themselves are in the docker image.


Right.

To clarify, the docker logs described in the original post of this thread refer to the container logs and not the docker service log.

The container logs reside in the docker image and are essentially the system logs of each container. They can and often do get out of hand when the container encounters an issue and the log is spammed repeatedly.

Afaik, on unraid, these logs never get rotated or cleaned, and can fill up the docker image without the user realizing it. I would like to reiterate the feature request of adding log size limit functionality to the docker service for the container logs.

The current version of docker supports the log option "max-size" for the json-file log driver.

https://docs.docker.com/engine/admin/logging/json-file/

Thanks
  • Upvote 1
Link to comment


Right.

To clarify, the docker logs described in the original post of this thread refer to the container logs and not the docker service log.

The container logs reside in the docker image and are essentially the system logs of each container. They can and often do get out of hand when the container encounters an issue and the log is spammed repeatedly.

Afaik, on unraid, these logs never get rotated or cleaned, and can fill up the docker image without the user realizing it. I would like to reiterate the feature request of adding log size limit functionality to the docker service for the container logs.

The current version of docker supports the log option "max-size" for the json-file log driver.

https://docs.docker.com/engine/admin/logging/json-file/

Thanks
@Squid also pointed out that you need max-file=1, otherwise the log gets rotated and is still in the image.
Link to comment
  • 2 weeks later...

@limetech @eric @jonp

 

I just wanted to make sure this didn't get lost in the pile.

 

To summarize, unraid currently does not have log rotation features of docker enabled for the json logging driver, which can cause issues with log files getting too large and filling up the docker image.

 

Docker has built-in log rotation / limitation feature, which can be enabled through configuring the service with the following options

--log-opt max-size=10m    #with k, m, or g
--log-opt max-file=3

source: https://docs.docker.com/engine/admin/logging/json-file/#options

 

I would appreciate it if this would be incorporated in the next stable

 

Thanks

  • Upvote 2
Link to comment
7 hours ago, aptalca said:

@limetech @eric @jonp

 

I just wanted to make sure this didn't get lost in the pile.

 

To summarize, unraid currently does not have log rotation features of docker enabled for the json logging driver, which can cause issues with log files getting too large and filling up the docker image.

 

Docker has built-in log rotation / limitation feature, which can be enabled through configuring the service with the following options


--log-opt max-size=10m    #with k, m, or g
--log-opt max-file=3

source: https://docs.docker.com/engine/admin/logging/json-file/#options

 

I would appreciate it if this would be incorporated in the next stable

 

Thanks

 

I will forward this to the rest of the team for feedback.  Thanks for posting and including all the details!

  • Upvote 1
Link to comment
  • 2 months later...

Thanks for this. 

 

Turns out my sonarr linuxserver docker was occupying 6.5g of log space due to it being set as trace level for whatever reason

 

Changed it to info, edited the container and now the docker.img is only 32% filled. 

 

Guess the log rotation is still not implemented in 6.3.5? Or maybe its the docker maintainer who hasnt implemented the support?

Link to comment
Log rotation is available on Docker level only, meaning when you start the Docker service it applies the Log setting to all containers. Currently this feature is available in unRAID version 6.4-rc7 and later.
 

Great thanks!

In less than 12 hours i can see it has grown to 400mb now, looking forward to 6.4!!

Sent from my LG-H990 using Tapatalk

Link to comment
  • 4 months later...
  • 3 weeks later...
  • 7 months later...
co=$(docker inspect --format='{{.Name}}' $(docker ps -aq --no-trunc) | sed 's/^.\(.*\)/\1/' | sort); for c_name in $co; do c_size=$(docker inspect --format={{.ID}} $c_name | xargs -I @ sh -c 'ls -hl /var/lib/docker/containers/@/@-json.log' | awk '{print $5 }'); YE='\033[1;33m'; NC='\033[0m'; PI='\033[1;35m'; RE='\033[1;31m'; case "$c_size" in *"K"*) c_size=${YE}$c_size${NC};; *"M"*) p=${c_size%.*}; q=${p%M*}; r=${#q}; if [[ $r -lt 3 ]]; then c_size=${PI}$c_size${NC}; else c_size=${RE}$c_size${NC}; fi ;;  esac;  echo -e "$c_name $c_size"; done

Single command to produce a list of log-sizes per container.

 

image.png.d47998fe56923903b821e13c29ff65ea.png

 

Edited by Osiris
  • Upvote 2
Link to comment

Hey there, I believe I've been seeing this issue with the Resilio Sync docker, but even after setting the log rotation options in the GUI it doesn't seem to have helped. Switched the container back on yesterday, and by this evening the JSON log had reached 5.2G. Specifically, the offending file is the one with a filename like /var/lib/docker/containers/<docker ID>/<docker ID>-json.log; are the GUI options for something else?

Link to comment
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.