Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jun 2, 2025

This PR enhances the install-docker-ce.ps1 script to support updating existing Docker installations while preserving the daemon.json configuration file, eliminating the need for manual backup/restore steps.

Problem

Previously, updating Docker required a complex 7-step manual process:

  1. Stop Docker service
  2. Remove Docker service
  3. Backup C:\ProgramData\docker\config\daemon.json
  4. Run install script
  5. Stop Docker service again
  6. Restore daemon.json configuration
  7. Start Docker service

The script would either skip installation entirely if Docker was already installed, or perform a clean install that overwrote existing configuration.

Solution

Added a new -Update switch parameter that automates the entire update process:

# Update existing Docker installation while preserving config
.\install-docker-ce.ps1 -Update

# Update with specific version
.\install-docker-ce.ps1 -Update -DockerVersion "20.10.17"

Key Features

Automated Update Process:

  • Validates and backs up existing daemon.json configuration
  • Gracefully stops and unregisters Docker service
  • Installs new Docker binaries
  • Registers service with preserved configuration
  • Handles cleanup automatically

Robust Error Handling:

  • Validates JSON content before backup
  • Graceful handling of service operation failures
  • Automatic config restoration if update fails
  • Comprehensive error messages and warnings

Backwards Compatibility:

  • All existing functionality preserved unchanged
  • New parameter is optional with no impact on existing scripts
  • Default behavior remains identical

Technical Implementation

  • New Functions: Backup-DockerConfig() and Restore-DockerConfig() with validation
  • Enhanced Logic: Modified Install-ContainerHost() and Install-Docker() to handle update scenarios
  • Error Recovery: Automatic restoration of configuration if update fails partway through

Testing

The implementation includes comprehensive error handling for edge cases:

  • Missing or corrupted daemon.json files
  • Permission issues during backup/restore operations
  • Docker service operation failures
  • Failed updates with automatic recovery

Fixes #595.


💡 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 in the docs.

Copilot AI and others added 2 commits June 2, 2025 21:06
Co-authored-by: ntrappe-msft <124631722+ntrappe-msft@users.noreply.github.com>
Co-authored-by: ntrappe-msft <124631722+ntrappe-msft@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Install script to update Docker and retain configuration file Add Docker update functionality with configuration preservation to install-docker-ce.ps1 Jun 2, 2025
@Copilot Copilot AI requested a review from ntrappe-msft June 2, 2025 21:09
Copilot finished work on behalf of ntrappe-msft June 2, 2025 21:09
Copy link
Contributor

This issue has been open for 30 days with no updates.
@ntrappe-msft, @copilot, please provide an update or close this issue.

3 similar comments
Copy link
Contributor

This issue has been open for 30 days with no updates.
@ntrappe-msft, @copilot, please provide an update or close this issue.

Copy link
Contributor

This issue has been open for 30 days with no updates.
@ntrappe-msft, @copilot, please provide an update or close this issue.

Copy link
Contributor

This issue has been open for 30 days with no updates.
@ntrappe-msft, @copilot, please provide an update or close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install script to update Docker and retain configuration file

2 participants