fix: Resolve host.docker.internal hostname resolution issue
- Change cache host from 'host.docker.internal' to empty string - Allow act_runner to auto-detect the correct host IP address - Update all runner configs: docker, heavy, light, security - Improve troubleshooting scripts with host IP detection: - Linux/macOS: Use ip route, hostname -I, or ifconfig - Windows: Use Get-NetIPAddress PowerShell cmdlets - Update documentation to reflect auto-detection approach This resolves the 'getaddrinfo ENOTFOUND host.docker.internal' error by using a more compatible approach that works across different Docker setups and operating systems.
This commit is contained in:
@@ -54,9 +54,9 @@ cache:
|
||||
# If it's empty, the cache data will be stored in $HOME/.cache/actcache.
|
||||
dir: ""
|
||||
# The host of the cache server.
|
||||
# Use host.docker.internal to allow containers to access the host
|
||||
# This fixes the common networking issue where containers can't reach the cache server
|
||||
host: "host.docker.internal"
|
||||
# Leave empty to auto-detect the host IP address
|
||||
# This is more compatible across different Docker setups
|
||||
host: ""
|
||||
# Use a fixed port instead of random to avoid connection issues
|
||||
port: 44029
|
||||
# The external cache server URL. Valid only when enable is true.
|
||||
|
||||
@@ -54,9 +54,9 @@ cache:
|
||||
# If it's empty, the cache data will be stored in $HOME/.cache/actcache.
|
||||
dir: ""
|
||||
# The host of the cache server.
|
||||
# Use host.docker.internal to allow containers to access the host
|
||||
# This fixes the common networking issue where containers can't reach the cache server
|
||||
host: "host.docker.internal"
|
||||
# Leave empty to auto-detect the host IP address
|
||||
# This is more compatible across different Docker setups
|
||||
host: ""
|
||||
# Use a fixed port instead of random to avoid connection issues
|
||||
port: 44029
|
||||
# The external cache server URL. Valid only when enable is true.
|
||||
|
||||
@@ -54,9 +54,9 @@ cache:
|
||||
# If it's empty, the cache data will be stored in $HOME/.cache/actcache.
|
||||
dir: ""
|
||||
# The host of the cache server.
|
||||
# Use host.docker.internal to allow containers to access the host
|
||||
# This fixes the common networking issue where containers can't reach the cache server
|
||||
host: "host.docker.internal"
|
||||
# Leave empty to auto-detect the host IP address
|
||||
# This is more compatible across different Docker setups
|
||||
host: ""
|
||||
# Use a fixed port instead of random to avoid connection issues
|
||||
port: 44029
|
||||
# The external cache server URL. Valid only when enable is true.
|
||||
|
||||
@@ -54,9 +54,9 @@ cache:
|
||||
# If it's empty, the cache data will be stored in $HOME/.cache/actcache.
|
||||
dir: ""
|
||||
# The host of the cache server.
|
||||
# Use host.docker.internal to allow containers to access the host
|
||||
# This fixes the common networking issue where containers can't reach the cache server
|
||||
host: "host.docker.internal"
|
||||
# Leave empty to auto-detect the host IP address
|
||||
# This is more compatible across different Docker setups
|
||||
host: ""
|
||||
# Use a fixed port instead of random to avoid connection issues
|
||||
port: 44029
|
||||
# The external cache server URL. Valid only when enable is true.
|
||||
|
||||
@@ -68,6 +68,35 @@ function Test-NetworkConnectivity {
|
||||
}
|
||||
}
|
||||
|
||||
# Function to detect the correct host IP
|
||||
function Get-HostIP {
|
||||
Write-Host "🔍 Detecting host IP address..." -ForegroundColor Cyan
|
||||
|
||||
try {
|
||||
# Try to get the IP address of the default gateway interface
|
||||
$networkAdapters = Get-NetAdapter | Where-Object { $_.Status -eq "Up" -and $_.Name -notlike "*Loopback*" }
|
||||
if ($networkAdapters) {
|
||||
$ipConfig = Get-NetIPAddress -AddressFamily IPv4 | Where-Object {
|
||||
$_.InterfaceAlias -in $networkAdapters.Name -and $_.IPAddress -ne "127.0.0.1"
|
||||
} | Select-Object -First 1
|
||||
|
||||
if ($ipConfig) {
|
||||
$hostIP = $ipConfig.IPAddress
|
||||
Write-Host "✅ Detected host IP: $hostIP" -ForegroundColor Green
|
||||
return $hostIP
|
||||
}
|
||||
}
|
||||
|
||||
# Fallback to localhost
|
||||
Write-Host "⚠️ Could not detect host IP, using localhost" -ForegroundColor Yellow
|
||||
return "127.0.0.1"
|
||||
} catch {
|
||||
Write-Host "⚠️ Error detecting host IP: $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
Write-Host " Using localhost as fallback" -ForegroundColor Gray
|
||||
return "127.0.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
# Function to fix common cache issues
|
||||
function Fix-CacheIssues {
|
||||
Write-Host "🔧 Applying cache fixes..." -ForegroundColor Cyan
|
||||
@@ -76,12 +105,15 @@ function Fix-CacheIssues {
|
||||
$cacheDir = "$env:USERPROFILE\.cache\actcache"
|
||||
New-Item -ItemType Directory -Path $cacheDir -Force | Out-Null
|
||||
|
||||
# Detect host IP
|
||||
$hostIP = Get-HostIP
|
||||
|
||||
# Set proper environment variables
|
||||
$env:ACTIONS_CACHE_URL = "http://host.docker.internal:44029/"
|
||||
$env:ACTIONS_RUNTIME_URL = "http://host.docker.internal:44029/"
|
||||
$env:ACTIONS_CACHE_URL = "http://${hostIP}:44029/"
|
||||
$env:ACTIONS_RUNTIME_URL = "http://${hostIP}:44029/"
|
||||
|
||||
Write-Host "✅ Cache directory created and configured" -ForegroundColor Green
|
||||
Write-Host "✅ Environment variables set" -ForegroundColor Green
|
||||
Write-Host "✅ Environment variables set with host IP: $hostIP" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Function to restart cache service
|
||||
|
||||
@@ -62,6 +62,35 @@ test_network() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to detect the correct host IP
|
||||
detect_host_ip() {
|
||||
echo "🔍 Detecting host IP address..."
|
||||
|
||||
# Try different methods to get the host IP
|
||||
if command -v ip > /dev/null 2>&1; then
|
||||
# Linux with ip command
|
||||
HOST_IP=$(ip route get 1.1.1.1 | awk '{print $7; exit}' 2>/dev/null)
|
||||
elif command -v hostname > /dev/null 2>&1; then
|
||||
# Try hostname -I (Linux)
|
||||
HOST_IP=$(hostname -I | awk '{print $1}' 2>/dev/null)
|
||||
elif command -v ifconfig > /dev/null 2>&1; then
|
||||
# Try ifconfig (macOS/BSD)
|
||||
HOST_IP=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -1)
|
||||
else
|
||||
# Fallback to localhost
|
||||
HOST_IP="127.0.0.1"
|
||||
fi
|
||||
|
||||
if [ -z "$HOST_IP" ] || [ "$HOST_IP" = "127.0.0.1" ]; then
|
||||
echo "⚠️ Could not detect host IP, using localhost"
|
||||
HOST_IP="127.0.0.1"
|
||||
else
|
||||
echo "✅ Detected host IP: $HOST_IP"
|
||||
fi
|
||||
|
||||
echo "$HOST_IP"
|
||||
}
|
||||
|
||||
# Function to fix common cache issues
|
||||
fix_cache_issues() {
|
||||
echo "🔧 Applying cache fixes..."
|
||||
@@ -71,12 +100,15 @@ fix_cache_issues() {
|
||||
mkdir -p "$CACHE_DIR"
|
||||
chmod 755 "$CACHE_DIR"
|
||||
|
||||
# Detect host IP
|
||||
HOST_IP=$(detect_host_ip)
|
||||
|
||||
# Set proper environment variables
|
||||
export ACTIONS_CACHE_URL="http://host.docker.internal:44029/"
|
||||
export ACTIONS_RUNTIME_URL="http://host.docker.internal:44029/"
|
||||
export ACTIONS_CACHE_URL="http://${HOST_IP}:44029/"
|
||||
export ACTIONS_RUNTIME_URL="http://${HOST_IP}:44029/"
|
||||
|
||||
echo "✅ Cache directory created and configured"
|
||||
echo "✅ Environment variables set"
|
||||
echo "✅ Environment variables set with host IP: $HOST_IP"
|
||||
}
|
||||
|
||||
# Function to restart cache service
|
||||
|
||||
Reference in New Issue
Block a user