Docker for Windows should resync VM time when computer resumes from sleep

I’m using @cristualexandru solution to update the time in the container every time I unlock my computer.

Prerequisites (There should be a possibility for most operating systems):

  • Windows 10 (or a possibility to start a command at login)
  • Installed “bash” (Cygwin or similar) environment installed
  1. Create a file “docker-sync-time.bat” with the following content:

    @echo off

    echo Syncing docker container time…
    bash -c “docker run --net=host --ipc=host --uts=host --pid=host --security-opt=seccomp=unconfined --privileged --rm alpine date -s “$(date -u ‘+%%Y-%%m-%%d %%H:%%M:%%S’)””

  2. Start “Task Scheduler”

  3. Add a task (“Task Scheduler Library” -> “Create New Task…”) that starts the batch script every time you login

2 Likes