Docker无法解析.net标准类库,将.net核心应用程序部署到Docker [英] Docker unable to resolve .net standard class libraries, on deploying .net core app to Docker
问题描述
我的docker文件如下,加在我的.net核心应用程序中:
FROM microsoft / dotnet:1.1-sdk-projectjson
COPY。 / app
WORKDIR / app
RUN [dotnet,restore]
RUN [dotnet,build]
EXPOSE 5000 / tcp
ENV ASPNETCORE_URLS http:// *:5000
ENTRYPOINT [dotnet,run]
它无法解析.net标准类库,它们被添加到我的.net核心应用程序中。
我的项目结构如下:
核心文件夹
/ pre>
-Logging.Interfaces .net std project
-Logging.Entities .net std项目
基础架构文件夹
-Infrastructure.Logging .net std项目
服务文件夹
-Services .net std project
Web文件夹
-Web .net核心应用程序
Web应用程序的project.json的依赖关系部分如下:
{
dependencies:{
Microsoft.NETCore.App:{
version:1.0.0,
type:平台
},
Microsoft.ApplicationInsights.AspNetCore:1.0.0,
Microsoft.AspNetCore.Mvc:1.0.1,
Microsoft.AspNetCore.Routing :1.0.1,
Microsoft.AspNetCore.Server.IISIntegration:1.0.0,
Microsoft.AspNetCore.Server.Kestrel:1.0.1,
Microsoft.Extensions.Configuration.EnvironmentVariables:1.0.0,
Microsoft.Extensions.Configuration.FileExtensions:1.0.0,
Microsoft.Extensions.Configuration.Json :1.0.0,
Microsoft.Extensions.Logging:1.0.0,
Microsoft.Extensions.Logging.Console:1.0.0,
Microsoft.Extensions.Logging.Debug:1.0.0,
Microsoft.Extensions.Options.ConfigurationExtensions:1.0.0,
服务:1.0.0- * ,
DomainInterfaces:1.0.0- *,
Core.Logging.Interfaces:1.0.0- *,
Core.Logging.Entities: 1.0.0- *,
Infrastructure.Logging:1.0.0- *
},
当我运行f为了创建图像,它给我错误:
user @ machine_name MINGW64解决路径
$ docker build -t helloWorld:core。
无法解析'.NETCoreApp,Version = v1.1'的'Core.Logging.Interfaces(> = 1.0.0)'。
无法解析'.NETCoreApp,Version = v1.1'的'Core.Logging.Entities(> = 1.0.0)'。
无法解析'.NETCoreApp,Version = v1.1'的'Services(> = 1.0.0)'。
无法解析'.NETCoreApp,Version = v1.1'的'Infrastructure.Logging(> = 1.0.0)'。
无法解析'.NETCoreApp,Version = v1.1'的'DomainInterfaces(> = 1.0.0)'。
有人可以指导,这里出了什么问题,因为我对Docker是全新的。 / p>
解决方案我认为你应该尝试在解决方案层面创建一个Dockerfile,如下所示:
/ YourProject
- src
- 核心
- 基础设施
- 服务
- WebApp
- Dockerfile
并将Dockerfile的内容更改为:
FROM microsoft / dotnet:1.1-sdk-projectjson
/ pre>
COPY。 / app
WORKDIR / app / src / WebApp
RUN [dotnet,restore]
RUN [dotnet,build]
EXPOSE 5000 / tcp
ENV ASPNETCORE_URLS http:// *:5000
ENTRYPOINT [dotnet,run]
希望这个帮助!
I am deploying .net core app to Docker.
My docker file is as follows, which is added in my .net core application:
FROM microsoft/dotnet:1.1-sdk-projectjson COPY . /app WORKDIR /app RUN ["dotnet", "restore"] RUN ["dotnet", "build"] EXPOSE 5000/tcp ENV ASPNETCORE_URLS http://*:5000 ENTRYPOINT ["dotnet", "run"]
Its not able to resolve .net standard class libraries, which are added to my .net core application.
My project structure is as follows:
Core folder -Logging.Interfaces .net std project -Logging.Entities .net std project Infrastructure folder -Infrastructure.Logging .net std project Services folder -Services .net std project Web folder -Web .net core application
Dependencies section of project.json of Web application is as follows:
{ "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0", "type": "platform" }, "Microsoft.ApplicationInsights.AspNetCore": "1.0.0", "Microsoft.AspNetCore.Mvc": "1.0.1", "Microsoft.AspNetCore.Routing": "1.0.1", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", "Microsoft.Extensions.Logging": "1.0.0", "Microsoft.Extensions.Logging.Console": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", "Services": "1.0.0-*", "DomainInterfaces": "1.0.0-*", "Core.Logging.Interfaces": "1.0.0-*", "Core.Logging.Entities": "1.0.0-*", "Infrastructure.Logging": "1.0.0-*" },
When I run following command, for creating image, it gives me error:
user@machine_name MINGW64 path to solution $ docker build -t helloWorld:core . Unable to resolve 'Core.Logging.Interfaces (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'. Unable to resolve 'Core.Logging.Entities (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'. Unable to resolve 'Services (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'. Unable to resolve 'Infrastructure.Logging (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'. Unable to resolve 'DomainInterfaces (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
Can someone please guide, what is going wrong over here, as I am completely new to Docker.
解决方案I think you should be tried to create a Dockerfile on solution level as following structure:
/YourProject
- src
- Core
- Infrastructure
- Services
- WebApp
- Dockerfile
And changes content of Dockerfile to:
FROM microsoft/dotnet:1.1-sdk-projectjson
COPY . /app
WORKDIR /app/src/WebApp
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000
ENTRYPOINT ["dotnet", "run"]
Hope this help!
这篇关于Docker无法解析.net标准类库,将.net核心应用程序部署到Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!