Skip to content

Commit

Permalink
fix: gracefully handle comments in resolv.conf. Fixes #171
Browse files Browse the repository at this point in the history
  • Loading branch information
4141done committed Oct 2, 2023
1 parent ddb616e commit 32dbb9b
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions common/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,11 @@ parseBoolean() {

# This line is an addition to the NGINX Docker image's entrypoint script.
if [ -z ${DNS_RESOLVERS+x} ]; then
resolvers=""
for ip in $(grep nameserver /etc/resolv.conf | cut -d' ' -f2 | xargs)
do
if echo "${ip}" | grep -q ':'; then
resolvers="$resolvers [${ip}]"
else
resolvers="$resolvers $ip"
fi
done
export DNS_RESOLVERS="${resolvers}"
# This method of pulling individual nameservers from
# /etc/resolv.conf taken from the entrypoint script in the
# official docker image.
# https://github.com/nginxinc/docker-nginx/blob/master/entrypoint/15-local-resolvers.envsh
export DNS_RESOLVERS="$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print $2}' /etc/resolv.conf)"
fi

# Normalize the CORS_ENABLED environment variable to a numeric value
Expand Down

0 comments on commit 32dbb9b

Please sign in to comment.