简体   繁体   English

为什么在运行ASP.NET Framework 4.7应用程序时docker容器的时间戳错误?

[英]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.

相关问题 在Docker容器中运行ASP.NET 4.6应用程序-站点始终为404s - Running ASP.NET 4.6 application inside a docker container - Site always 404s 运行我的Asp.net 4应用程序时出错 - Error when running my Asp.net 4 application How to setup https when developing localy with webpack and hosting on Azure in Docker container running ASP.NET Core - How to setup https when developing localy with webpack and hosting on Azure in Docker container running ASP.NET Core asp.net framework 4.7 配置日志级别,不工作 - asp.net framework 4.7 configure logging level, not working 运行为Docker应用程序时出现React.Aspnet错误的ASP.NET Core 2.1 Web应用程序 - ASP.NET Core 2.1 Web application with React.Aspnet error when running as Docker application IIS安装特性下,.net framework 4.7和asp.net 4.7有什么区别 - Under IIS installation features, what is the difference between .net framework 4.7 and asp.net 4.7 如何将ASP.NET应用程序部署到Linux服务器上的Docker容器? - How to deploy asp.net application to docker container on Linux server? 如何使用Docker容器设置ASP.NET Web应用程序 - How to setup ASP.NET Web Application with Docker container 为什么 ASP.NET 加载了错误版本的 Web 应用程序程序集? - Why does ASP.NET load the wrong version of my web application assembly? Web 应用程序 ASP.NET Framework 不显示我的页面 - Web Application ASP.NET Framework do not show my page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM