Windows: Podman 가상 머신 DNS 자동 점검·복구 (이미지 받기·빌드 전)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K3UWnbHEdCxxWhyNx7Cpd2
This commit is contained in:
@@ -2786,6 +2786,30 @@ function Confirm-PodmanMachine {
|
|||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 가상 머신 안에서 인터넷 주소를 찾는지(DNS) 확인하고, 안 되면 DNS 설정 파일을 만들어 고정
|
||||||
|
# (WSL이 /etc/resolv.conf 를 만들지 못해 이미지 받기·빌드가 'name resolution' 오류로 실패하는 경우)
|
||||||
|
function Repair-MachineDns {
|
||||||
|
$sh = @'
|
||||||
|
if getent hosts registry-1.docker.io >/dev/null 2>&1; then echo DNS_OK; exit 0; fi
|
||||||
|
gw=$(ip route | awk '/^default/{print $3; exit}')
|
||||||
|
rm -f /etc/resolv.conf
|
||||||
|
{ [ -n "$gw" ] && echo "nameserver $gw"; echo "nameserver 8.8.8.8"; echo "nameserver 1.1.1.1"; } > /etc/resolv.conf
|
||||||
|
grep -q '^\[network\]' /etc/wsl.conf 2>/dev/null || printf '\n[network]\ngenerateResolvConf = false\n' >> /etc/wsl.conf
|
||||||
|
if getent hosts registry-1.docker.io >/dev/null 2>&1; then echo DNS_FIXED; else echo DNS_FAIL; fi
|
||||||
|
'@
|
||||||
|
$b64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(($sh -replace "`r`n", "`n")))
|
||||||
|
$mi = Get-MachineInfo
|
||||||
|
$r = "$(& $script:PodmanExe machine ssh $mi.Name "echo $b64 | base64 -d | sudo sh" 2>$null)"
|
||||||
|
if ($r -match 'DNS_OK') { return $true }
|
||||||
|
if ($r -match 'DNS_FIXED') {
|
||||||
|
Write-C "${GREEN}✅ 가상 머신이 인터넷 주소를 찾지 못해(DNS) 설정을 고쳤습니다.${RESET}"
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
Write-C "${YELLOW}⚠️ 가상 머신에서 인터넷 주소를 찾지 못합니다(DNS). 이미지 받기가 실패할 수 있습니다.${RESET}"
|
||||||
|
Write-C "${GRAY} 이 PC의 인터넷 연결을 확인하거나 'podman machine stop' 후 다시 시도해 주세요.${RESET}"
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
# 컨테이너 상태 (State: none/running/exited/paused/created..., Status: 한글 상태 문구)
|
# 컨테이너 상태 (State: none/running/exited/paused/created..., Status: 한글 상태 문구)
|
||||||
function Get-WebuiInfo {
|
function Get-WebuiInfo {
|
||||||
$info = [pscustomobject]@{ State = 'none'; Status = '' }
|
$info = [pscustomobject]@{ State = 'none'; Status = '' }
|
||||||
@@ -2822,6 +2846,7 @@ function New-WebuiContainer {
|
|||||||
& $script:PodmanExe image exists $WebuiImage 2>$null
|
& $script:PodmanExe image exists $WebuiImage 2>$null
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-C "${GREEN}Open WebUI 이미지를 받는 중입니다 (처음 한 번, 수 GB)...${RESET}"
|
Write-C "${GREEN}Open WebUI 이미지를 받는 중입니다 (처음 한 번, 수 GB)...${RESET}"
|
||||||
|
[void](Repair-MachineDns)
|
||||||
& $script:PodmanExe pull $WebuiImage | Out-Host
|
& $script:PodmanExe pull $WebuiImage | Out-Host
|
||||||
if ($LASTEXITCODE -ne 0) { Write-C "${RED}❌ 이미지를 받지 못했습니다.${RESET}"; return $false }
|
if ($LASTEXITCODE -ne 0) { Write-C "${RED}❌ 이미지를 받지 못했습니다.${RESET}"; return $false }
|
||||||
}
|
}
|
||||||
@@ -3068,6 +3093,7 @@ function Update-Webui {
|
|||||||
$old = "$(& $script:PodmanExe container inspect $WebuiName --format '{{.Image}}' 2>$null)".Trim()
|
$old = "$(& $script:PodmanExe container inspect $WebuiName --format '{{.Image}}' 2>$null)".Trim()
|
||||||
if ($LASTEXITCODE -ne 0) { $old = '' }
|
if ($LASTEXITCODE -ne 0) { $old = '' }
|
||||||
Write-C "${GREEN}`n최신 Open WebUI 이미지를 확인하는 중...${RESET}"
|
Write-C "${GREEN}`n최신 Open WebUI 이미지를 확인하는 중...${RESET}"
|
||||||
|
[void](Repair-MachineDns)
|
||||||
& $script:PodmanExe pull $WebuiImage | Out-Host
|
& $script:PodmanExe pull $WebuiImage | Out-Host
|
||||||
if ($LASTEXITCODE -ne 0) { Write-C "${RED}❌ 이미지를 받지 못했습니다.${RESET}"; return }
|
if ($LASTEXITCODE -ne 0) { Write-C "${RED}❌ 이미지를 받지 못했습니다.${RESET}"; return }
|
||||||
$new = "$(& $script:PodmanExe image inspect $WebuiImage --format '{{.Id}}' 2>$null)".Trim()
|
$new = "$(& $script:PodmanExe image inspect $WebuiImage --format '{{.Id}}' 2>$null)".Trim()
|
||||||
@@ -3771,6 +3797,7 @@ function Build-ComfyImage($Inst, [switch]$Fresh) {
|
|||||||
if ($Fresh) { $bust = (Get-Date -Format 'yyyyMMddHHmmss') }
|
if ($Fresh) { $bust = (Get-Date -Format 'yyyyMMddHHmmss') }
|
||||||
Write-C "${GREEN}`nComfyUI $($Inst.Ref) 이미지를 만드는 중입니다...${RESET}"
|
Write-C "${GREEN}`nComfyUI $($Inst.Ref) 이미지를 만드는 중입니다...${RESET}"
|
||||||
Write-C "${GRAY} 처음 한 번은 Python·PyTorch(CPU)를 받느라 5~15분 걸립니다. 다른 버전은 공통 부분을 재사용해 빠릅니다.${RESET}"
|
Write-C "${GRAY} 처음 한 번은 Python·PyTorch(CPU)를 받느라 5~15분 걸립니다. 다른 버전은 공통 부분을 재사용해 빠릅니다.${RESET}"
|
||||||
|
[void](Repair-MachineDns)
|
||||||
& $script:PodmanExe build -t $Inst.Image --build-arg "COMFY_REF=$($Inst.Ref)" --build-arg "CACHE_BUST=$bust" -f (Join-Path $ComfyBuildDir 'Containerfile') $ComfyBuildDir | Out-Host
|
& $script:PodmanExe build -t $Inst.Image --build-arg "COMFY_REF=$($Inst.Ref)" --build-arg "CACHE_BUST=$bust" -f (Join-Path $ComfyBuildDir 'Containerfile') $ComfyBuildDir | Out-Host
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-C "${RED}❌ 이미지를 만들지 못했습니다. 인터넷 연결과 버전 이름($($Inst.Ref))을 확인해 주세요.${RESET}"
|
Write-C "${RED}❌ 이미지를 만들지 못했습니다. 인터넷 연결과 버전 이름($($Inst.Ref))을 확인해 주세요.${RESET}"
|
||||||
|
|||||||
Reference in New Issue
Block a user