Files
JamBalaya56562andClaude Opus 4.8 d0129d48a2 fix: respect user-provided RESOLVERS env var (#2699)
The entrypoint's _resolvers() unconditionally recomputed RESOLVERS from
/etc/resolv.conf and exported it, overwriting any value the user set via
the environment — contradicting the documented "no default value" behavior.

Now _resolvers() honors a user-provided RESOLVERS and only autodetects from
/etc/resolv.conf when it is unset/empty. Adds a "Custom DNS Resolvers" docs
section and an integration test covering both the honored and autodetected
cases.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 22:22:37 +09:00

27 lines
1.0 KiB
Python

import docker
docker_client = docker.from_env()
def _generated_config(container_name: str) -> str:
sut_container = docker_client.containers.get(container_name)
assert sut_container.status == "running"
exit_code, output = sut_container.exec_run("cat /etc/nginx/conf.d/default.conf")
assert exit_code == 0, output.decode()
return output.decode()
# Regression test for https://github.com/nginx-proxy/nginx-proxy/issues/2699:
# a user-provided RESOLVERS value must be honored and not overwritten by the
# entrypoint's autodetection from /etc/resolv.conf.
def test_user_provided_resolvers_is_honored(docker_compose):
config = _generated_config("resolvers-custom")
assert "resolver 8.8.8.8;" in config
# When RESOLVERS is not set, the entrypoint should still autodetect the resolvers
# from /etc/resolv.conf (Docker's embedded DNS on a user-defined network).
def test_resolvers_are_autodetected_when_unset(docker_compose):
config = _generated_config("resolvers-auto")
assert "resolver 127.0.0.11;" in config