Skip to main content

Docker Windows容 器中的时间问题

· 2 min read

场景 #1:

主机 OS 版本: Windows 10 1803 容器 OS 版本: Windows Server Core 1803

容器以默认的 hyperv 模式启动, 空器中的时间是一个莫名其妙的未来时间,比主机的时间提前 10 多个小时: 主机的时间是 2018-8-15 17:XX:XX, 容器中的时间是 2018-8-16 07:XX:XX 又一次代码修改重新构建了容器的镜像,重启了容器,容器的时间与主机的时间同步了

测试: 1. 当前实际时间为 2018-8-16 16:XX:XX, 关掉主机中的自动设置时间, 修改主机的时间为 2018-5-16 16:XX:XX,容器中的时间不变,重启容器后容器中的时间变成 2018-8-16 09:XX:XX 2. 打开主机中自动设置时间,主机时间变回,2018-8-16 16:07:XX, 容器的时间也跟着同步成了 2018-8-16 16:07:XX 3. 再次关掉主机中的自动设置时间,把主机时间改为 2018-8-19 16:07:XX, 容器的时间马上跟着变成了 2018-8-19 16:07:XX 4. 再次打开主机中的自动设置时间,主机时间变回 2018-8-16 16:09:XX, 容器时间还维持在 2018-8-19 16:XX:XX 5. 再次重启容器,容器的时间又与主机同步了

结论: 当容器中的时间比主机的时间晚时,与立即与主机时间同步,反之则不会同步。莫名其妙, 参见 bug: https://github.com/moby/moby/issues/37283

场景 #2:

主机 OS 版本: Windows Server 2016 14393.1358 容器 OS 版本: Windows Server Core 10.0.14393.2363

容器以 process 模式启动, docker run ... --isolation process... 不管主机时间如果变化,容器中的时间都与主机时间同步

hyperv 或 process 兼容列表见: https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility

Docker for Windows 18.06.0-ce released

· 2 min read
  • Upgrades

  • New

  • Bug fixes and minor changes

    • AUFS storage driver is deprecated in Docker Desktop and AUFS support will be removed in the next major release. You can continue with AUFS in Docker Desktop 18.06.x, but you will need to reset disk image (in Settings > Reset menu) before updating to the next major update. You can check documentation to save images and backup volumes
    • Fix bug which would cause VM logs to be written to RAM rather than disk in some cases, and the VM to hang.
    • Fix security issue with named pipe connection to docker service.
    • Fix VPNKit memory leak. Fixes docker/for-win#2087, moby/vpnkit#371
    • Fix restart issue when using Windows fast startup on latest 1709 Windows updates. Fixes docker/for-win#1741, docker/for-win#1741
    • DNS name host.docker.internal can be used for host resolution from Windows Containers. Fixes docker/for-win#1976
    • Fix broken link in diagnostics window.
    • Added log rotation for docker-ce logs inside the virtual machine.
    • Changed smb permission to avoid issue when trying to manipulate files with different users in containers. Fixes docker/for-win#2170
ClustrMaps