Created
July 5, 2025 13:20
-
-
Save wazeerc/55c562c3a62bedef9e697c944689d9ab to your computer and use it in GitHub Desktop.
Docker alias for Powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Docker alias - starts Docker Desktop when typing docker | |
function Start-Docker { | |
# Check if Docker Desktop is already running | |
$dockerProcess = Get-Process -Name "Docker Desktop" -ErrorAction SilentlyContinue | |
if (-not $dockerProcess) { | |
Write-Host "Starting Docker Desktop..." -ForegroundColor Yellow | |
Start-Process -FilePath "C:\Program Files\Docker\Docker\Docker Desktop.exe" -WindowStyle Hidden | |
# Wait a moment for Docker to start | |
Start-Sleep -Seconds 3 | |
Write-Host "Docker Desktop started!" -ForegroundColor Green | |
} else { | |
Write-Host "Docker Desktop is already running." -ForegroundColor Green | |
} | |
# Run the original docker command with any passed arguments | |
if ($args.Count -gt 0) { | |
& docker.exe @args | |
} | |
} | |
Set-Alias -Name docker -Value Start-Docker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment