Docker daemon general log extra parameters.


jairbj

Recommended Posts

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 by jairbj
Link to comment
  • 2 weeks later...
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.

Link to comment
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.

  • Like 1
Link to comment
  • 1 year later...
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?

Link to comment
  • 2 weeks later...
  • 1 month later...

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 by Saad
  • Thanks 1
Link to comment

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.