Time in Docker container our of sync with host machine

前端 未结 1 789
萌比男神i
萌比男神i 2021-01-15 18:17

I\'m trying to connect to CosmosDB through my SpringBoot app. I have all of this working if I run the app with Spring or via Int

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 18:56

    Docker containers don't maintain a separate clock, it's identical to the Linux host since time is not a namespaced value. This is also why Docker removes the permission to change the time inside the container, since that would impact the host and other containers, breaking the isolation model.

    However, on Docker Desktop, docker runs inside of a VM (allowing you to run Linux containers on non-Linux desktops), and that VM's time can get out of sync when the laptop is suspended. This is currently being tracked in an issue over on github which you can follow to see the progress: https://github.com/docker/for-win/issues/4526

    Potential solutions include restarting your computer, restarting docker's VM, running NTP as a privileged container, or resetting the time sync in the windows VM with the following PowerShell:

    Get-VMIntegrationService -VMName DockerDesktopVM -Name "Time Synchronization" | Disable-VMIntegrationService
    Get-VMIntegrationService -VMName DockerDesktopVM -Name "Time Synchronization" | Enable-VMIntegrationService
    

    With WSL 2, restarting the VM involves:

    wsl --shutdown
    wsl
    

    0 讨论(0)
提交回复
热议问题