for-win icon indicating copy to clipboard operation
for-win copied to clipboard

WindowsServerCore 1709 base image has wrong date / time context relative to local docker host

Open douglaswaights opened this issue 9 years ago • 37 comments

Expected behavior

Spin up a 1709 server core base image and do a Powershell get-date in the container and it should match the local date time context of the docker host it was spun up in...as with previous versions of the server core base image.

Actual behavior

There is a different date time from your local environment

Information

I discovered this developing a web app based on windowsservercore1709 which authenticates with azureAD. This fails because of a date time mismatch between the container and the azureAD service with token exchange in OpenID.

Steps to reproduce the behavior

  1. Spin up the 1709 server core base image and do an interactive ps cmd and do get-date
  2. Compare this with previous versions of the base image which have the same date time context as the local docker host

What is the best way to ensure the date time is correct via a docker build file. Have you got an example of this.

Thanks Doug

douglaswaights avatar Nov 06 '17 12:11 douglaswaights

@patricklang is this because you've now fixed that leak where a process in a container could set date and time on the host?

friism avatar Nov 06 '17 16:11 friism

@douglaswaights I've been able to repro this on my local machine with all the :1709 images I've tested. It seems to to be related to a fix for another issue where changing the containers timezone would change the hosts as well.

jasonbivins avatar Nov 07 '17 19:11 jasonbivins

@jasonbivins thanks for confirming.

hmmm - Have you any suggestions for a workaround as this seems to be a blocker for 1709 - presumably for others too.

I've attempted to start W32Time with a cmd in the docker file and via powershell in the container directly but no success.

@friism has pointed out to me in another thread that, unless running with hyperv isolation, then when running 1709 on bare metal (azure windows server core with containers 1709 vm image for example) you can only run 1709 images...

douglaswaights avatar Nov 07 '17 21:11 douglaswaights

paging @patricklang ...

friism avatar Nov 07 '17 21:11 friism

What time zone are you trying to change? Do you want the hosting machine to be UTC or local time, and the container to be the other?

PatrickLang avatar Nov 07 '17 23:11 PatrickLang

@PatrickLang From what i've seen in my testing - there's a behaviour change in the 1709 images. Every other server and core image gives you the host's local time and timezone Depending on which one of these you use - the time command gives you different results docker run -it microsoft/nanoserver:latest cmd vs docker run -it microsoft/nanoserver:1709 cmd
Linux containers give you UTC

jasonbivins avatar Nov 08 '17 00:11 jasonbivins

I can't explain this, but now for some reason the 1709 base images seem to show the correct time. Get-date in both my local dev environment and azure VM seem s to be correct for the containers.

Is it possible some other external service they were reliant on was down before?

I still cant start the W32Time service in the containers, but i don't need to now as the clock issues have been resolved for me and azure AD token exchange time mismatch is no longer happening.

douglaswaights avatar Nov 08 '17 16:11 douglaswaights

@douglaswaights I can confirm that nanoserver:1709 and windowsservercore:1709 both match the hosts local time and zone now - I'll go ahead and close this one, but please feel free to re-open it if you notice this again!

jasonbivins avatar Nov 08 '17 21:11 jasonbivins

Hi again @jasonbivins @friism @PatrickLang

The problem has resurfaced again today in my local dev environment. Please can you reopen the issue.

The windowsservercore 1709 image hasn't changed but i now see the time in the container being reported as 6.20pm (locally the time is actually 12:20 pm) in Norway (UTC +1). The get-timezone is correct in the container. Therefore the container is wrong and inconsistent with itself.

Interestingly on this occasion the azure VM (with exactly the same base container image) is reporting the correct time and timezone. (when i saw this before both the azure vm and local dev env were wrong).

The azure vm is actually running in a different time zone (UTC +00) compared to my my local env (utc +01) which is interesting.

I've tried restarting Docker and my machine several times but no improvement.

Please can someone explain how this could be happening.

How does server core figure what the time is?

Thanks Doug

douglaswaights avatar Nov 09 '17 11:11 douglaswaights

Same issue here. This happen only with images based on 1709. The system (Windows 10) had no other images, with only the 1709 image installed

image

The first terminal is the host the second one is the container

image

image

If i use the microsoft/windowsservercore:ltsc2016 image it works as expected:

image

I tested the same scenario on two different machines (at home and at work). Both are windows 10 system, so both run containers with hyper-v isolation ( i dont known if it matter). I did not test this on Windows Server 2016 with simple container to verify if the behavior is the same.

@jasonbivins Can this issue be reopened? Or do i need to open another issue?

Thanks.

D3-LucaPiombino avatar Dec 04 '17 08:12 D3-LucaPiombino

I've seen exactly the same problem - the nanoserver:1709 image has a time that is totally different to the nanoserver:latest image.

docker version
Client:
 Version:      17.09.1-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:22:26 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.09.1-ce
 API version:  1.32 (minimum version 1.24)
 Go version:   go1.8.3
 Git commit:   19e2cf6
 Built:        Thu Dec  7 22:32:40 2017
 OS/Arch:      windows/amd64
 Experimental: true

Running that at 10:30, I get two different results.

First with nanoserver latest

docker run --rm -i -t microsoft/nanoserver:latest
time

responds with 10:30:00.58

Then with 1709

docker run --rm -i -t microsoft/nanoserver:1709
time

responds with 17:17:23.25

In fact, every time I start up nanoserver:1709, the time is 17:17:23 (ish) - depending on how fast I type 'time'

nrandell avatar Dec 19 '17 10:12 nrandell

Any fix? Hitting the same issue with 1709.

neilortoo avatar Jan 03 '18 13:01 neilortoo

@jasonbivins @friism @PatrickLang

Can you reopen this issue? i´m unable to...

Thanks

douglaswaights avatar Jan 03 '18 18:01 douglaswaights

@douglaswaights re-opened

I'll setup and try to repro this again later on today

jasonbivins avatar Jan 03 '18 18:01 jasonbivins

@jasonbivins, hey how is this repro coming along? Also may be worth removing the "fixed" status label from here?

AndrewSav avatar Jan 16 '18 06:01 AndrewSav

Having the same problem with microsoft/aspnet:4.7.1-windowsservercore-1709. No fix yet?

joostmeijles avatar Jan 16 '18 11:01 joostmeijles

Can confirm the issue is present on both microsoft/dotnet-framework:latest and microsoft/dotnet-framework-build:latest. Im in utc+1 timezone but container seems to be in utc+10. So when host time is 08:00 container time is 17:00..

however the timezone in the container is W.Europe Standard Time which is correct.

netbrain avatar Jan 19 '18 07:01 netbrain

Same problem with microsoft/windowsservercore:1709 on Win10: this is very troublesome as VSTS agent refuse to install when it sees more than 5 minutes of time skew.

giuliov avatar Jan 22 '18 11:01 giuliov

@giuliov Yeah, this is exacly my use case... I was trying to dockerize the vsts agent and found this issue

D3-LucaPiombino avatar Jan 22 '18 12:01 D3-LucaPiombino

Having same problem right now. I'm just running a simple .NET console app.

When I go to connect to my Azure Document DB instance, things fail because the access tokens are created for a certain timespan by the server, which can be whenever, then sent back to the client, then attempt to be used by the client immediately. Because the time is WAYY off, the server says the token is not valid for the current time. I run my local machines in UTC, so this doesn't seem to make any sense.

The resultant error is like the following:

Please create another token and retry (token start time: Thu, 25 Jan 2018 05:44:55 GMT, token expiry time: Thu, 25 Jan 2018 05:59:55 GMT, current server time: Wed, 24 Jan 2018 22:01:09 GMT).

I live in the US, so the given time is incorrect regardless!

jamesbascle avatar Jan 24 '18 22:01 jamesbascle