Skip to content

Instantly share code, notes, and snippets.

@ebell451
Last active October 26, 2023 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebell451/63208b8bc86859b4fb463fcd432eb241 to your computer and use it in GitHub Desktop.
Save ebell451/63208b8bc86859b4fb463fcd432eb241 to your computer and use it in GitHub Desktop.
Install Docker Engine on Windows
<#
==================================================================================================================
Script to Install Docker Engine on Windows
==================================================================================================================
Created: 05/19/2023
Author: Ethan Bell
GitHub: ebell451
==================================================================================================================
Purpose: This script will either install or update Docker Engine on a Windows machine.
The folder you specify to download the artifacts must already exist.
==================================================================================================================
Inspiration: https://docs.docker.com/engine/install/binaries/#install-server-and-client-binaries-on-windows
==================================================================================================================
#>
$DrvLetter = Read-Host -Prompt 'What drive letter, no colon, are you downloading to?'
$DirName = Read-Host -Prompt 'What directory are you wanting to save the file to?'
$Version = ((Invoke-WebRequest -Uri https://download.docker.com/win/static/stable/x86_64/).Links | Select-Object href | select-object -last 1 -expandproperty href)
Start-BitsTransfer -Source https://download.docker.com/win/static/stable/x86_64/$Version -Destination "${DrvLetter}:\${DirName}\${Version}"
$Service = Get-Service -Name Docker -ErrorAction SilentlyContinue
if ($null -ne $Service) {
Stop-Service Docker
}
Expand-Archive "${DrvLetter}:\${DirName}\${Version}" -DestinationPath $Env:ProgramFiles -Force
if ($null -eq $Service) {
&$Env:ProgramFiles\Docker\dockerd --register-service
}
Start-Service Docker
Get-Service Docker
@ebell451
Copy link
Author

Demonstration
2023-05-19_13-12-21

@ebell451
Copy link
Author

ebell451 commented May 19, 2023

There are easier ways if you want to use package managers in Windows such as:

  • Chocolately
    choco install docker
    choco install docker-compose

  • Scoop
    scoop install main/docker
    scoop install docker-compose

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