Add uninstall-docker-ce.ps1 script with -Force flag support
## Summary
This PR creates a new `uninstall-docker-ce.ps1` script to provide a clean way to remove Docker Community Edition from Windows systems. The script includes a `-Force` flag that bypasses user confirmation prompts for automated uninstallation scenarios.
## Changes Made
### New Files
- **`helpful_tools/Install-DockerCE/uninstall-docker-ce.ps1`** - Complete Docker CE uninstallation script
- **Updated `helpful_tools/Install-DockerCE/README.md`** - Added documentation for the new uninstall script
### Key Features
#### -Force Flag Implementation
The `-Force` parameter enables automated uninstallation by bypassing all user confirmation prompts:
```powershell
# Interactive mode - prompts for confirmation before each operation
.\uninstall-docker-ce.ps1
# Automated mode - proceeds without user input
.\uninstall-docker-ce.ps1 -Force
# Automated with Windows features removal
.\uninstall-docker-ce.ps1 -Force -RemoveWindowsFeatures
```
#### Comprehensive Uninstall Functionality
The script reverses all operations performed by `install-docker-ce.ps1`:
- ✅ Stops Docker service if running
- ✅ Removes Docker service registration
- ✅ Removes Docker binaries (`docker.exe`, `dockerd.exe`) from System32
- ✅ Cleans up Docker data directory (containers, images, volumes, configuration)
- ✅ Removes custom Docker networks
- ✅ Optionally removes Windows Container features
#### Additional Safety Parameters
- **`-KeepData`** - Preserves Docker data directory and configuration files
- **`-RemoveWindowsFeatures`** - Removes Windows Container features (use with caution)
- **`-WhatIf`** - Shows what would be done without making changes
#### Error Handling & Compatibility
- Proper administrator privilege checking
- Graceful handling of missing components
- Cross-platform compatibility for development/testing
- Comprehensive error handling with meaningful messages
## Usage Examples
```powershell
# Basic uninstall with prompts
.\uninstall-docker-ce.ps1
# Force uninstall without prompts
.\uninstall-docker-ce.ps1 -Force
# Preview what would be uninstalled
.\uninstall-docker-ce.ps1 -WhatIf
# Complete removal including Windows features
.\uninstall-docker-ce.ps1 -Force -RemoveWindowsFeatures
# Uninstall but keep data
.\uninstall-docker-ce.ps1 -Force -KeepData
```
## Documentation
The script includes comprehensive help documentation following PowerShell best practices:
- `.SYNOPSIS` and `.DESCRIPTION` sections
- Detailed parameter documentation with examples
- Multiple usage examples for different scenarios
- Updated README.md with complete reference
## Testing
- ✅ Parameter validation and help system
- ✅ -Force flag bypasses prompts correctly
- ✅ WhatIf mode for safe testing
- ✅ Cross-platform compatibility
- ✅ PowerShell best practices compliance
- ✅ Consistent coding style with existing scripts
This script provides users with a reliable way to cleanly remove Docker CE installations, with the `-Force` flag enabling automation scenarios while maintaining safety through confirmation prompts by default.
---
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
合并状态:未合并 关闭于 2025-06-03 0 条评论