From a4c9ab2462dd66819b2be1eebb6be5fe1a1a5312 Mon Sep 17 00:00:00 2001 From: Ventz Petkov Date: Fri, 6 Mar 2020 23:23:35 -0500 Subject: [PATCH] Added new BIND_LOG environment variable. By default you still have -g, however you can now override directly with -f for foreground logging. The README also has a detailed section on logging practices. I've also updated the binary version to the latest Alpine image v3.11.3 --- README.md | 16 +++++++++++++++- container/Dockerfile | 5 +++++ container/entrypoint.sh | 5 +++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5193a2b..6be1328 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,20 @@ logging { category default { stdout; }; }; +For more information, see: https://www.slideshare.net/MenandMice/bind-9-logging-best-practices + +## How do I just change Bind STDERR to STDOUT logging? + +There is now a "BIND_LOG" ENV (environment) variable for logging + +Environment variables can both have a default and be customized at run time. + +``` +"-g" = (default) Run the server in the foreground and force all logging stderr. +"-f" = Run the server in the foreground ``` -For more information, see: https://www.slideshare.net/MenandMice/bind-9-logging-best-practices +By default, the "-g" value is set, as that logs all to STDERR. +You can now override it with "-f" by passing `-e "BIND_LOG=-f"` to `docker run` + + diff --git a/container/Dockerfile b/container/Dockerfile index 4760b2b..4a0ef75 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -3,6 +3,11 @@ EXPOSE 53 53/udp RUN apk --update upgrade && apk add bind bind-tools bind-plugins +# BIND Log Options - you can override at run time +# "-g" = (default) Run the server in the foreground and force all logging stderr. +# "-f" = Run the server in the foreground +env BIND_LOG -g + # /etc/bind needs to be owned by root, group owned by "bind", and chmod 750 # since we are mounting, do it manually # NOTE: Per Dockerfile manual --> need to mkdir the mounted dir to chown diff --git a/container/entrypoint.sh b/container/entrypoint.sh index 72fbd79..922db1d 100755 --- a/container/entrypoint.sh +++ b/container/entrypoint.sh @@ -4,5 +4,6 @@ chown -R root:named /etc/bind /var/run/named chown -R named:named /var/cache/bind chmod -R 770 /var/cache/bind /var/run/named chmod -R 750 /etc/bind -# Run in foreground and log to STDERR (console): -exec /usr/sbin/named -c /etc/bind/named.conf -g -u named $OPTIONS +# By default - run in foreground and log to STDERR (console) +# can be changed by running container with: -e "BIND_LOG=-f" +exec /usr/sbin/named -c /etc/bind/named.conf $BIND_LOG -u named $OPTIONS