From 2799768484342e488ae7b9c3c56348255e890b34 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sat, 24 Jan 2026 12:11:02 +0000 Subject: [PATCH] Add debug logging to container detection - Added logger import and declaration following pkg:filename convention - Added logging for function entry - Added logging for each detection method success - Added logging when no container environment is detected This provides visibility into which container detection method succeeds, helping troubleshoot containerization issues. --- internal/tty/container.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/tty/container.go b/internal/tty/container.go index e1f6f316..bab8812b 100644 --- a/internal/tty/container.go +++ b/internal/tty/container.go @@ -3,12 +3,19 @@ package tty import ( "os" "strings" + + "github.com/githubnext/gh-aw-mcpg/internal/logger" ) +var log = logger.New("tty:container") + // IsRunningInContainer detects if the current process is running inside a container func IsRunningInContainer() bool { + log.Print("Detecting container environment") + // Method 1: Check for /.dockerenv file (Docker-specific) if _, err := os.Stat("/.dockerenv"); err == nil { + log.Print("Container detected: /.dockerenv file exists") return true } @@ -20,14 +27,17 @@ func IsRunningInContainer() bool { strings.Contains(content, "containerd") || strings.Contains(content, "kubepods") || strings.Contains(content, "lxc") { + log.Printf("Container detected: found container indicator in /proc/1/cgroup") return true } } // Method 3: Check environment variable (set by Dockerfile) if os.Getenv("RUNNING_IN_CONTAINER") == "true" { + log.Print("Container detected: RUNNING_IN_CONTAINER=true") return true } + log.Print("No container environment detected") return false }