Spaces:
Paused
Paused
| # Configure Docker Desktop to use D:\dOCKER | |
| # Run as Administrator | |
| param( | |
| [string]$DockerPath = "D:\dOCKER" | |
| ) | |
| Write-Host "π³ Docker Windows Path Configuration" -ForegroundColor Cyan | |
| Write-Host "=====================================" -ForegroundColor Cyan | |
| Write-Host "" | |
| # Check if running as Administrator | |
| $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
| if (-not $isAdmin) { | |
| Write-Host "β This script must be run as Administrator!" -ForegroundColor Red | |
| Write-Host "Right-click PowerShell and select 'Run as Administrator'" -ForegroundColor Yellow | |
| exit 1 | |
| } | |
| # Check if Docker Desktop is running | |
| Write-Host "π Checking Docker Desktop status..." -ForegroundColor Yellow | |
| $dockerRunning = Get-Process "Docker Desktop" -ErrorAction SilentlyContinue | |
| if ($dockerRunning) { | |
| Write-Host "β οΈ Docker Desktop is running. Please close it before continuing." -ForegroundColor Yellow | |
| $response = Read-Host "Close Docker Desktop now? (Y/N)" | |
| if ($response -eq "Y" -or $response -eq "y") { | |
| Stop-Process -Name "Docker Desktop" -Force -ErrorAction SilentlyContinue | |
| Start-Sleep -Seconds 3 | |
| } else { | |
| Write-Host "β Please close Docker Desktop manually and run this script again." -ForegroundColor Red | |
| exit 1 | |
| } | |
| } | |
| # Check if path exists | |
| if (-not (Test-Path $DockerPath)) { | |
| Write-Host "β Path does not exist: $DockerPath" -ForegroundColor Red | |
| Write-Host "Creating directory..." -ForegroundColor Yellow | |
| New-Item -ItemType Directory -Path $DockerPath -Force | Out-Null | |
| } | |
| # Check WSL distributions | |
| Write-Host "" | |
| Write-Host "π Checking WSL distributions..." -ForegroundColor Yellow | |
| $wslList = wsl --list --verbose 2>&1 | |
| Write-Host $wslList | |
| # Check if docker-desktop-data exists | |
| $hasDockerData = $wslList -match "docker-desktop-data" | |
| $hasDockerDesktop = $wslList -match "docker-desktop" | |
| if ($hasDockerData -or $hasDockerDesktop) { | |
| Write-Host "" | |
| Write-Host "β οΈ Docker Desktop WSL distributions found." -ForegroundColor Yellow | |
| Write-Host "You have two options:" -ForegroundColor Yellow | |
| Write-Host "" | |
| Write-Host "Option 1: Use Docker Desktop Settings (Recommended)" -ForegroundColor Cyan | |
| Write-Host " 1. Open Docker Desktop" -ForegroundColor White | |
| Write-Host " 2. Go to Settings β Resources β Advanced" -ForegroundColor White | |
| Write-Host " 3. Change 'Disk image location' to: $DockerPath" -ForegroundColor White | |
| Write-Host " 4. Click 'Apply & Restart'" -ForegroundColor White | |
| Write-Host "" | |
| Write-Host "Option 2: Manual WSL Migration (Advanced)" -ForegroundColor Cyan | |
| Write-Host " See DOCKER_WINDOWS_CONFIG.md for detailed instructions" -ForegroundColor White | |
| Write-Host "" | |
| } else { | |
| Write-Host "β No Docker Desktop WSL distributions found." -ForegroundColor Green | |
| Write-Host "Docker Desktop will use default location or configured path." -ForegroundColor Green | |
| } | |
| # Verify Docker path structure | |
| Write-Host "" | |
| Write-Host "π Checking Docker path structure..." -ForegroundColor Yellow | |
| $expectedPath = Join-Path $DockerPath "wsl\DockerDesktopWSL\data" | |
| if (Test-Path $expectedPath) { | |
| Write-Host "β Found Docker data at: $expectedPath" -ForegroundColor Green | |
| # List contents | |
| Write-Host "" | |
| Write-Host "Contents:" -ForegroundColor Cyan | |
| Get-ChildItem -Path $expectedPath -Recurse -Depth 2 | Select-Object FullName, Length | Format-Table -AutoSize | |
| } else { | |
| Write-Host "β οΈ Expected path not found: $expectedPath" -ForegroundColor Yellow | |
| Write-Host "This is normal if Docker Desktop hasn't been configured yet." -ForegroundColor Yellow | |
| } | |
| # Check .wslconfig | |
| Write-Host "" | |
| Write-Host "π Checking .wslconfig..." -ForegroundColor Yellow | |
| $wslConfigPath = "$env:USERPROFILE\.wslconfig" | |
| if (Test-Path $wslConfigPath) { | |
| Write-Host "β Found .wslconfig at: $wslConfigPath" -ForegroundColor Green | |
| Write-Host "" | |
| Write-Host "Current content:" -ForegroundColor Cyan | |
| Get-Content $wslConfigPath | |
| } else { | |
| Write-Host "β οΈ .wslconfig not found. Creating template..." -ForegroundColor Yellow | |
| $wslConfigContent = @" | |
| [wsl2] | |
| # Memory limit (adjust based on your system) | |
| memory=4GB | |
| # CPU cores (adjust based on your system) | |
| processors=2 | |
| # Swap file location | |
| swap=$($DockerPath.Replace('\', '\\'))\\wsl\\swap.vhdx | |
| # Page reporting (better performance) | |
| pageReporting=true | |
| # VM idle timeout | |
| vmIdleTimeout=60000 | |
| "@ | |
| $wslConfigContent | Out-File -FilePath $wslConfigPath -Encoding UTF8 | |
| Write-Host "β Created .wslconfig at: $wslConfigPath" -ForegroundColor Green | |
| } | |
| # Summary | |
| Write-Host "" | |
| Write-Host "=====================================" -ForegroundColor Cyan | |
| Write-Host "β Configuration Check Complete" -ForegroundColor Green | |
| Write-Host "" | |
| Write-Host "Next Steps:" -ForegroundColor Yellow | |
| Write-Host "1. Open Docker Desktop" -ForegroundColor White | |
| Write-Host "2. Go to Settings β Resources β Advanced" -ForegroundColor White | |
| Write-Host "3. Set 'Disk image location' to: $DockerPath" -ForegroundColor White | |
| Write-Host "4. Click 'Apply & Restart'" -ForegroundColor White | |
| Write-Host "" | |
| Write-Host "For detailed instructions, see: DOCKER_WINDOWS_CONFIG.md" -ForegroundColor Cyan | |
| Write-Host "" | |