From cd977be93d31228933dfa583011b6ca6cae350fc Mon Sep 17 00:00:00 2001 From: casjay Date: Fri, 5 Jun 2026 15:44:44 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Re-apply=20resolv.conf=20in=20in?= =?UTF-8?q?it.d=20phase=20to=20beat=20Docker's=20async=20rewrite=20?= =?UTF-8?q?=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docker writes /etc/resolv.conf at container start before PID1 launches, and again asynchronously when the network finishes initializing. The entrypoint's early copy gets overwritten by Docker's second write. Re-applying the custom resolv.conf in __run_precopy (init.d phase) happens after Docker's network setup is complete, so the search . and options ndots:0 settings stick for the full container lifetime. - rootfs/usr/local/etc/docker/init.d/08-gitea.sh: copy custom resolv.conf in __run_precopy rootfs/usr/local/etc/docker/init.d/08-gitea.sh --- rootfs/usr/local/etc/docker/init.d/08-gitea.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rootfs/usr/local/etc/docker/init.d/08-gitea.sh b/rootfs/usr/local/etc/docker/init.d/08-gitea.sh index 2eb0041..b9e9cb0 100755 --- a/rootfs/usr/local/etc/docker/init.d/08-gitea.sh +++ b/rootfs/usr/local/etc/docker/init.d/08-gitea.sh @@ -287,8 +287,10 @@ __run_precopy() { # Define environment local hostname=${HOSTNAME} [ -d "/run/healthcheck" ] || mkdir -p "/run/healthcheck" - # Define actions/commands - + # Re-apply custom resolv.conf — Docker rewrites /etc/resolv.conf asynchronously + # during container startup, after the entrypoint's initial copy. Applying it here + # (in the init.d phase) ensures it takes effect after Docker finishes network setup. + [ -f "/usr/local/etc/resolv.conf" ] && cp -f "/usr/local/etc/resolv.conf" "/etc/resolv.conf" 2>/dev/null || true # allow custom functions if builtin type -t __run_precopy_local | grep -q 'function'; then __run_precopy_local; fi }