我们使用Visual Studio 2017的项目模板" .NET核心Web应用程序(模型 - 视图 - 控制器)"创建了一个应用程序,选择"更改身份验证 - >个人用户帐户"
然后我们开发了应用程序并且正在阅读以推送我们的第一个容器。
发布到文件夹后,我们通过运行
在发布文件夹中进行了测试dotnet nameof.dll
所有测试都通过了。来自docker log
的代码段:
Hosting environment: Production
Content root path: \publish
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
到目前为止一切顺利。
然后我们尝试使用此Dockerfile
构建一个简单的容器:
FROM microsoft/aspnetcore:2
WORKDIR app
EXPOSE 80
COPY publish .
CMD ["dotnet", "nameof.dll"]
该网站出现但有警告。
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {8f452e97-17ae-45cb-bcfb-d97a81ce1199} may be persisted to storage in unencrypted form.
Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
除此之外,一切都很好。浏览网站。看起来不错。
当我们尝试登录时抛出此异常:
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: System.DirectoryServices.Protocols is not supported on this platform.
System.PlatformNotSupportedException: System.DirectoryServices.Protocols is not supported on this platform.
at System.DirectoryServices.Protocols.DirectoryIdentifier..ctor()
at System.DirectoryServices.Protocols.LdapDirectoryIdentifier..ctor(String server)
at CycleMenu.Controllers.AccountController.<Login>d__11.MoveNext() in C:\gg\AramarkCycleMenu\src\CycleMenu\CycleMenu\Controllers\AccountController.cs:line 78
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
很明显,docker镜像中缺少某些内容,但如果它不在发布文件夹中,那么它在哪里?怎么能在容器外面工作但不在里面工作?
我们试过了
根据此讨论:https://github.com/dotnet/corefx/issues/2089 System.DirectoryServices.Protocols
最初未包含在.NET Core中,但现在是(2017年11月)。可能是码头中心上的图像还不是最新的,这就是为什么我们得到这个平台&#34; ...不支持这个平台&#34;?
运行dotnet --version
会在容器内部和外部返回2.1.4。
您能否提供任何帮助或见解如何解决此错误并将其他正常工作的代码正确地插入docker镜像?
编辑回答:在Windows 10上运行Docker for Windows
答案 0 :(得分:0)
我在基于System.DirectoryServices.Protocols
的dotnet core 3.0 docker容器中使用Nuget软件包4.6.0
版本mcr.microsoft.com/dotnet/core/aspnet:3.0
遇到了相同的问题。
但是,正如我们在您提到的问题中所看到的那样,除了Windows:https://github.com/dotnet/corefx/issues/2089#issuecomment-373219911
不支持其他平台。