flnxi-Wu/scripts/deploy/check-docker.ps1
WuYongJie f646b71813
Some checks failed
CI Check / check (push) Has been cancelled
chore: 初始化本地仓库并同步最近改动
2025-11-18 17:50:16 +08:00

45 lines
1.9 KiB
PowerShell

# Check Docker images on server
param(
[string]$Server = "45.249.208.118",
[string]$User = "root",
[string]$Password = "lxvhNYFZ4160"
)
$ErrorActionPreference = "Stop"
Write-Host "Checking Docker images on server..." -ForegroundColor Cyan
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
if (-not (Test-Path $plinkPath)) {
Write-Host "Error: plink.exe not found" -ForegroundColor Red
exit 1
}
Write-Host "`n[1/4] Checking Docker version..." -ForegroundColor Yellow
& $plinkPath -ssh -pw $Password -batch "${User}@${Server}" "docker --version"
Write-Host "`n[2/4] Checking local images (node:18-alpine)..." -ForegroundColor Yellow
$nodeImages = & $plinkPath -ssh -pw $Password -batch "${User}@${Server}" "docker images node:18-alpine 2>&1"
Write-Host $nodeImages
if ($nodeImages -match "node.*18-alpine") {
Write-Host "`n[OK] Server has node:18-alpine image locally" -ForegroundColor Green
Write-Host " No need to pull from registry, can build directly" -ForegroundColor Green
} else {
Write-Host "`n[WARN] Server does not have node:18-alpine image" -ForegroundColor Yellow
Write-Host " Need to pull from registry, but registry may have issues" -ForegroundColor Yellow
}
Write-Host "`n[3/4] Checking Docker registry configuration..." -ForegroundColor Yellow
$daemonConfig = & $plinkPath -ssh -pw $Password -batch "${User}@${Server}" "cat /etc/docker/daemon.json 2>&1"
Write-Host $daemonConfig
Write-Host "`n[4/4] Testing registry connection..." -ForegroundColor Yellow
$testConnection = & $plinkPath -ssh -pw $Password -batch "${User}@${Server}" "curl -I https://docker.1panel.live/v2/ 2>&1 | head -1"
Write-Host $testConnection
Write-Host "`n=== Summary ===" -ForegroundColor Cyan
Write-Host "If server has node:18-alpine image: can build directly" -ForegroundColor Green
Write-Host "If server does not have image: need to fix registry or use alternative source" -ForegroundColor Yellow