[英]Why is my docker container's timestamp wrong when running an ASP.NET Framework 4.7 application?
I have a very simple ASP.NET v4.7 web application that runs in a docker container on my local development laptop. 我有一个非常简单的ASP.NET v4.7 Web应用程序,该应用程序在本地开发笔记本电脑上的docker容器中运行。
The web application tries to connect to DocumentDb, but this fails because the container's timestamp is completely wrong, so naturally Jwt token verification fails. Web应用程序尝试连接到DocumentDb,但这失败了,因为容器的时间戳是完全错误的,因此Jwt令牌验证自然会失败。 The exact ASP.NET code does not really matter;
确切的ASP.NET代码并不重要。 this is more about why the docker container's timestamp is different from the host machine.
这更多地说明了为什么Docker容器的时间戳与主机不同。
Note that I'm using windows containers. 请注意,我正在使用Windows容器。 My dockerFile looks as follows:
我的dockerFile如下所示:
FROM microsoft/aspnet:4.7.2-windowsservercore-1803
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .
When I connect to the container, and run "time", I get the following: 当我连接到容器并运行“时间”时,得到以下信息:
docker container exec -it <containerId> cmd
c:\>time
The current time is: 0:29:49.87
c:\>tzutil /g
South Africa Standard Time
When I do this on the host machine, my laptop, I get: 在主机,笔记本电脑上执行此操作时,我得到:
C:\>time
The current time is: 15:42:45.72
Enter the new time:
C:\>tzutil /g
South Africa Standard Time
Where does docker get that crazy timestamp? 码头工人在哪里得到那个疯狂的时间戳? Is there a way to sync with the host machine on startup?
有没有一种在启动时与主机同步的方法?
My laptop's operating system version is: Win 10, v1803 (build 17134.471) I'm running: Docker for Windows CE v2.0.0.0-win81 (29211) with Docker Engine version 18.09.0 我的笔记本电脑的操作系统版本是:Win 10,v1803(内部版本17134.471)我正在运行:Docker for Windows CE v2.0.0.0-win81(29211)和Docker Engine版本18.09.0
Unfortunately the only solution so far is to "Wait and let it marinate" as pointed out in http://github.com/Microsoft/aspnet-docker/issues/120 不幸的是,到目前为止唯一的解决方案是“等待并使其腌制”,如http://github.com/Microsoft/aspnet-docker/issues/120中指出的那样
Thanks @ikkentim for pointing out the issue. 感谢@ikkentim指出问题。
I suspected that perhaps my container did not have internet access and could not sync its clock, but was unable to verify this as it just started working fine this morning. 我怀疑我的容器也许无法访问互联网并且无法同步其时钟,但由于今天早上才开始正常工作,因此无法对其进行验证。
I will post a better answer if I find a more useful solution than "wait". 如果找到比“等待”更有用的解决方案,我将发布更好的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.