jairbj Posted August 9, 2021 Share Posted August 9, 2021 (edited) Hi friends, I'd like to pass extra log parameters for all my docker containers. --log-driver json-file --log-opt tag="{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}" I know I can use "extra parameters" session for every container, but I'd like to do this in a global way. I tried creating a /etc/docker/daemon.json with these parms but when I started docker I got unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: log-opts: (from flag: map[max-file:1 max-size:50m], from file: map[tag:{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}]) I couldn't find a way to do this in unraid > settings > docker tab. Does anyone can help me with this? Edited August 9, 2021 by jairbj Quote Link to comment
mgutt Posted August 20, 2021 Share Posted August 20, 2021 On 8/9/2021 at 3:59 PM, jairbj said: tried creating a /etc/docker/daemon.json with these parms How does your json look like? On 8/9/2021 at 3:59 PM, jairbj said: the following directives are specified both as a flag and in the configuration file Maybe this happens because --log-opt is already defined in /etc/rc.d/rc.docker?! # Enable global docker LOG rotation if [[ $DOCKER_LOG_ROTATION == yes ]]; then [[ -z $DOCKER_LOG_SIZE ]] && DOCKER_LOG_SIZE=10m [[ -z $DOCKER_LOG_FILES ]] && DOCKER_LOG_FILES=1 DOCKER_OPTS="--log-opt max-size=$DOCKER_LOG_SIZE --log-opt max-file=$DOCKER_LOG_FILES $DOCKER_OPTS" fi ... nohup $UNSHARE --propagation slave -- $DOCKER -p $DOCKER_PIDFILE $DOCKER_OPTS >>$DOCKER_LOG 2>&1 & Try to edit this file. If this works, you could try to overwrite it through your Go file and "sed", so its permanent on reboot. Quote Link to comment
jairbj Posted August 21, 2021 Author Share Posted August 21, 2021 19 hours ago, mgutt said: How does your json look like? Maybe this happens because --log-opt is already defined in /etc/rc.d/rc.docker?! # Enable global docker LOG rotation if [[ $DOCKER_LOG_ROTATION == yes ]]; then [[ -z $DOCKER_LOG_SIZE ]] && DOCKER_LOG_SIZE=10m [[ -z $DOCKER_LOG_FILES ]] && DOCKER_LOG_FILES=1 DOCKER_OPTS="--log-opt max-size=$DOCKER_LOG_SIZE --log-opt max-file=$DOCKER_LOG_FILES $DOCKER_OPTS" fi ... nohup $UNSHARE --propagation slave -- $DOCKER -p $DOCKER_PIDFILE $DOCKER_OPTS >>$DOCKER_LOG 2>&1 & Try to edit this file. If this works, you could try to overwrite it through your Go file and "sed", so its permanent on reboot. Hi friend. Thank you for the TIP, solved it adding this to my GO file: sed -i '2 i DOCKER_OPTS="$DOCKER_OPTS --log-driver json-file --log-opt tag=\\\"{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}\\\""' /etc/rc.d/rc.docker Although it works, @limetech promised to add an "additional options" at docker settings page here. I couldn't find this option. 1 Quote Link to comment
KnifeTeck Posted January 10, 2023 Share Posted January 10, 2023 On 8/20/2021 at 8:37 PM, jairbj said: Hi friend. Thank you for the TIP, solved it adding this to my GO file: sed -i '2 i DOCKER_OPTS="$DOCKER_OPTS --log-driver json-file --log-opt tag=\\\"{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}\\\""' /etc/rc.d/rc.docker Although it works, @limetech promised to add an "additional options" at docker settings page here. I couldn't find this option. was this ever added? Quote Link to comment
spali Posted January 20, 2023 Share Posted January 20, 2023 Not till now as I know. At least not in docker settings page on version: 6.11.5. Quote Link to comment
Saad Posted February 22, 2023 Share Posted February 22, 2023 (edited) I see these is a file in /boot/config/docker.cfg where you can add $DOCKER_OPTS variable to contain the extra params for docker. I have this in my `/boot/config/docker.cfg`: DD_TAG="{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}" DOCKER_OPTS="$DOCKER_OPTS --log-opt tag=$DD_TAG" You will need to restart docker service via settings->docker Edited February 22, 2023 by Saad 1 Quote Link to comment
Recommended Posts
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.