From 7285b325d579df29494cede89329d32bfa783798 Mon Sep 17 00:00:00 2001 From: Landon Cox Date: Thu, 16 Apr 2026 13:05:57 -0700 Subject: [PATCH 1/2] Make /etc/hosts write non-fatal for non-root container execution gh-aw PR #26658 adds --user $(id -u):$(id -g) to the MCP gateway Docker run command so log files are readable by downstream steps. With set -e, the echo >> /etc/hosts in configure_host_dns() would abort the gateway when running as non-root. Fix: wrap the write in an if-else so failure is a warning, not fatal. With --network host the host.docker.internal mapping is unnecessary anyway since localhost works directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- run_containerized.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/run_containerized.sh b/run_containerized.sh index 0dedbf76..e2856a2e 100755 --- a/run_containerized.sh +++ b/run_containerized.sh @@ -285,9 +285,11 @@ configure_host_dns() { # Add host.docker.internal mapping to /etc/hosts # Check if the entry already exists to avoid duplicates if ! grep -q "host.docker.internal" /etc/hosts 2>/dev/null; then - log_info "Adding host.docker.internal mapping to /etc/hosts" - echo "$HOST_IP host.docker.internal" >> /etc/hosts - log_info "DNS mapping configured: $HOST_IP -> host.docker.internal" + if echo "$HOST_IP host.docker.internal" >> /etc/hosts 2>/dev/null; then + log_info "DNS mapping configured: $HOST_IP -> host.docker.internal" + else + log_warn "Cannot write to /etc/hosts (running as non-root?); host.docker.internal mapping skipped" + fi else log_info "host.docker.internal already exists in /etc/hosts" fi From 9459dd31a8632042cab47509cfd469c57a0a8254 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Apr 2026 21:08:02 +0000 Subject: [PATCH 2/2] Fix /etc/hosts append stderr suppression in non-root path Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/5ba53afd-63d5-4103-b7e0-e20725f32cf6 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --- run_containerized.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_containerized.sh b/run_containerized.sh index e2856a2e..40a66417 100755 --- a/run_containerized.sh +++ b/run_containerized.sh @@ -285,7 +285,7 @@ configure_host_dns() { # Add host.docker.internal mapping to /etc/hosts # Check if the entry already exists to avoid duplicates if ! grep -q "host.docker.internal" /etc/hosts 2>/dev/null; then - if echo "$HOST_IP host.docker.internal" >> /etc/hosts 2>/dev/null; then + if { echo "$HOST_IP host.docker.internal" >> /etc/hosts; } 2>/dev/null; then log_info "DNS mapping configured: $HOST_IP -> host.docker.internal" else log_warn "Cannot write to /etc/hosts (running as non-root?); host.docker.internal mapping skipped"