-
-
Save odalet/8f19719687068de996c5101e57c22a70 to your computer and use it in GitHub Desktop.
Synchronize your Docker date/time with the host clock - Mitigates https://github.com/docker/for-win/issues/4526
This file contains 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
# NB: "Time Synchronization" is "Synchronisation date/heure" in French | |
$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) | |
if (-Not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
Write-Host "Elevated privileges are required." | |
Start-Process -FilePath "powershell" -ArgumentList "$('-File ""')$(Get-Location)$('\')$($MyInvocation.MyCommand.Name)$('""')" -Verb runAs | |
exit | |
} | |
Write-Host "--- Synchronizing your docker time ---" | |
Write-Host "Current date is" | |
docker run --rm -it --entrypoint=date alpine:latest | |
# Let's retrieve the localized name of the Time sunc service | |
$name = (Get-VMIntegrationService -VMName DockerDesktopVM | Where-Object { $_.Id.StartsWith("Microsoft:") -and $_.Id.EndsWith("\2497F4DE-E9FA-4204-80E4-4B75C46419C0") }).Name # "Time Synchronization" for English Windows | |
Get-VMIntegrationService -VMName DockerDesktopVM -Name $name | Disable-VMIntegrationService | |
Get-VMIntegrationService -VMName DockerDesktopVM -Name $name | Enable-VMIntegrationService | |
Get-VMIntegrationService -VMName DockerDesktopVM | Format-Table | |
Write-Host "Time synced. Current date now is" | |
docker run --rm -it --entrypoint=date alpine:latest | |
Write-Host -NoNewLine "`r`nPress any key to exit" | |
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment