Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time sync differences between docker containers for Windows and the hosting machine #3168

Closed
tmarinov opened this issue Jan 2, 2019 · 19 comments

Comments

@tmarinov
Copy link

tmarinov commented Jan 2, 2019

DiagnosticsID: 1F3FB75F-3F5E-4EE0-8D08-4F7C2E233988/20190102225357

The following issue looks like this one:
#409
but there it is written/confirmed that it is fixed with the new (back then, 2017) version, while I am having the problem now, with the latest versions.
I started having an error when try to access CosmosDB from an api, contained in a Docker container hosted on my windows 10 (used to work before):

The authorization token is not valid at the current time. Please create another token and retry (token start time: Thu, 03 Jan 2019 01:47:43 GMT, token expiry time: Thu, 03 Jan 2019 02:02:43 GMT, current server time: Wed, 02 Jan 2019 22:48:57 GMT).
ActivityId: d5c7cf80-1465-4abb-9dd8-a22c6b8b35a9, Microsoft.Azure.Documents.Common/2.1.0.0, Windows/10.0.17134 documentdb-netcore-sdk/2.2.0

I see a few hours time difference between the docker container and my windows 10 laptop.
Here is my "anonymized" docker file:

`FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY Services//.API.csproj Services/.API/
COPY Services/
****.csproj Services//
RUN dotnet restore Services/.API.csproj
COPY . .
WORKDIR /src/Services/
********
RUN dotnet build *****.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish .API.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "
.API.dll"]
`

Started having this with image for 2.1 dotnet core. Since then:

  • restarted Docker for Windows (Version 2.0.0.0-win81 (29211); Channel: stable; Build: 4271b9e)
  • recreated the images/containers
  • Re-set Docker for Windows
  • Upgraded whole solution + images to dotnet core 2.2.

Without any success - still getting the same error.

Any ideas?
(The solution contains 4 containers in total, all of them are with the same time, but it is different from the host machine (my windows laptop. Same solution was working about 1 month ago - before Docker and Windows upgraded)

Update
If I do:
docker exec -it de7 cmd
and then:
C:\app> Time
I am getting:
The current time is: 3:15:18.44
which is 8 hours different than my hosting machine's current time.

But if I make a new file in the container:
C:\app> echo abc > MyFile.txt

I am getting the correct creation time:
01/02/2019 11:12 PM myfile.txt

@Sieabah
Copy link

Sieabah commented Jan 14, 2019

Install ntp on the container?

@TimZander
Copy link

I am having this issue as well, using aspnet:latest

@docker-robott
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@denissa4
Copy link

/remove-lifecyclestale

@JohanOhlin
Copy link

Has anyone come up with any solution to this problem? I ran into the same issue right now when trying to access CosmosDb container from a container using mcr.microsoft.com/dotnet/core/aspnet:2.2-nanoserver-1803 as base. Time difference is 8 hours for me also. When accessing the CosmosDb container from the host then I had no issues.

@Sieabah
Copy link

Sieabah commented Jul 4, 2019

Probably will need to install ntp so you're not relying on the docker clock

@JohanOhlin
Copy link

I managed to solve it in the end by upgrading to the latest Windows 10 version (10.0.18362) and was then also able to upgrade my container to use mcr.microsoft.com/dotnet/core/aspnet:2.2-nanoserver-1903 (compared to 1803 before). No more time problems causing certificate issues :-)

@coip
Copy link

coip commented Jan 15, 2020

As another datapoint, Im getting some ~similar behaviour:

edit: added windows context:

Microsoft Windows [Version 10.0.18362.145]
ethan@host:~$ echo "container: $(sudo docker run alpine date)" && echo "host:      $(TZ="UTC" date)"
container: Wed Jan 15 03:41:01 UTC 2020
host:      Wed Jan 15 20:06:12 UTC 2020

ethan@host:~$ sudo docker version
Client:
 Version:           18.09.7
 API version:       1.39
 Go version:        go1.10.1
 Git commit:        2d0083d
 Built:             Fri Aug 16 14:20:06 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea
  Built:            Wed Nov 13 07:29:19 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

@coip
Copy link

coip commented Jan 15, 2020

/remove-lifecycle stale

@nate-vukovich
Copy link

What I've done is simply restart the Docker environment and the sync was correctly done in the container.

@Mikk36
Copy link

Mikk36 commented Jan 27, 2020

I'm also seeing this behaviour after upgrading to Docker Desktop 2.2.

@coip
Copy link

coip commented Jan 27, 2020

What I've done is simply restart the Docker environment and the sync was correctly done in the container.

the restart is simple, knowing to expect telemetry submissions (etc, insert artibrary timesensitive processing here) arriving ~half a day off is the less simple/obvious complication here... 😅

@jimjam-slam
Copy link

Possibly the same as #4526 (I experienced it as API auth problems too!)

@davclark
Copy link

davclark commented Jan 29, 2020

As the person who opened #4526, I'm comfortable closing that one in favor of this one, or whichever issue is most informative at this point. There's a lot of chiming in on both.

I would have probably discovered this issue before opening mine if it had linked to #72.

@kkbruce
Copy link

kkbruce commented Feb 14, 2020

My computer datetime is "02/14/2020 02:50 PM". if run tag ":1803" image will get incorrect datetime.

  1. docker run -it --rm mcr.microsoft.com/windows/nanoserver:1803 cmd.exe
C:\>date /t
Sat 02/15/2020

C:\>time /t
06:51 AM
  1. docker run -it --rm mcr.microsoft.com/windows/servercore:1803 cmd.exe
C:\>date /t
Sat 02/15/2020

C:\>time /t
06:53 AM

If run tag ":1909" datetime is correct.

  1. docker run -it --rm mcr.microsoft.com/windows/nanoserver:1909 cmd.exe
C:\>date /t
Fri 02/14/2020

C:\>time /t
02:50 PM

docker version

C:\>docker version
Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea
 Built:             Wed Nov 13 07:22:37 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.24)
  Go version:       go1.12.12
  Git commit:       633a0ea
  Built:            Wed Nov 13 07:36:50 2019
  OS/Arch:          windows/amd64
  Experimental:     false

win ver:

C:\>ver

Microsoft Windows [版本 10.0.18363.592]

@liberdis
Copy link

liberdis commented Feb 18, 2020

Having the same issue with mcr.microsoft.com/dotnet/framework/aspnet:4.7.2 on Windows 10 (1903), containers consistently created with OS time two or more hours ahead of host. Restarting services/host provides no relief.

I believe this was introduced with the docker desktop update as my image has changed only superficially in the last few months and this issue presentation appears to have surfaced after the docker desktop update. I did experience this issue around a year ago, and a Docker Desktop update apparently resolved it.
EDIT: On another windows 10 (1903) machine I loaded up Docker Desktop 2.1 and ran the same image as above, and the container time matched the host. I'm in the process of downgrading my main development laptop from 2.2 to 2.1 to see if this resolves the problem.

@philippe-granet
Copy link

In release note:
https://docs.docker.com/docker-for-windows/release-notes/#docker-desktop-community-2203
Known issues:
In some cases, Docker containers do not synchronize time with the host when the host machine is put to sleep.

@stephen-turner
Copy link
Contributor

This is the same as #4526, and there's more discussion there, so I'm going to close this copy.

There is a new build at #4526 (comment) that you can try.

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Jul 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests