Closed lockejan closed 1 month ago
Hey @lockejan! Thanks for bringing this to our attention.
Can you show the /etc/resolv.conf from the container so we could reproduce?
Hey @lockejan! Thanks for bringing this to our attention.
Can you show the /etc/resolv.conf from the container so we could reproduce?
/ $ cat /etc/resolv.conf
# Generated by Docker Engine.
# This file can be edited; Docker Engine will not make further changes once it
# has been modified.
nameserver 127.0.0.11
options ndots:0
# Based on host file: '/etc/resolv.conf' (internal resolver)
# ExtServers: [192.168.65.7]
# Overrides: []
# Option ndots from: internal
I figured it's because of ORS option in the awk command.
NGINX_LOCAL_RESOLVERS=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {if ($2 ~ ":") {print "["$2"]"} else {print $2}}' /etc/resolv.conf)
https://github.com/nginxinc/docker-nginx-unprivileged/blob/main/entrypoint/15-local-resolvers.envsh#L11
If ORS=" "
is changed to ORS=""
it won't produce a trailing whitespace.
I was just about to create a PR, but as this project is a mirror I wasn't sure in which repo to open it.
https://github.com/nginxinc/docker-nginx would be best!
Yup! I will get to it once I have some spare time :)
Should have been fixed in https://github.com/nginxinc/docker-nginx-unprivileged/pull/238!
Describe the bug
When triggering the entrypoint script 15-local-resolver.envsh, it will always include a trailing whitespace in the env. In my nginx template I use "${NGINX_LOCAL_RESOLVERS}" as a placeholder. I usually use double quotes to prevent globbing and word splitting as described by SC2086.
After envsubst replaced the placeholder it will always contain the trailing whitespace. This causes nginx to crash because it can't resolve the host "127.0.0.11 ".
Even though SC2086 might not be applicable to sh and getting rid of the quotation marks would be sufficient as well, I couldn't find a single reason why this could be on purpose.
To reproduce
Steps to reproduce the behavior:
Expected behavior
NGINX_LOCAL_RESOLVERS being set without trailing whitespaces. E.g. "127.0.0.11" not "127.0.0.11 ".
Your environment
Additional context
Add any other context about the problem here.