Docker container with ASP.NET Core libraries

我是研究僧i 提交于 2019-12-12 03:46:22

问题


Each time I build Dockerfile with ASP.NET Core application it's download assemblies from web Nuget store.

Basically I'd like to create docker image with all this ASP.NET Core libraries (and probably some libraries I usually use).

From my understanding I trying to reinvent GAC.

So, my question is it possible to use something like GAC for ASP.NET Core? Or, my second thought, download ASP.NET Core libraries to container and then resolve it locally somehow.

My goal is to reduse time for building docker container.

UPDATE

Looks like it's impossible


回答1:


There is now an official .NET Core Docker image from Microsoft, with all the needed libraries.

You can get it here:

https://hub.docker.com/r/microsoft/aspnetcore/

If you need to customize it, don't forget you can modify the container and create a custom image with "docker commit".




回答2:


For ASP.NET core just use dnu to build your application into a self-contained folder.

dnu publish 

will output build the project and output it to /bin/output. There are a number of options at your disposal including the ability to specify the output path, choose framework or runtime and even to change the command for starting the web.

dnu publish --help

will give you more detail on that.




回答3:


If you want to contain a "package" (folder) that contains your application, its dependencies and the runtime then you have to run:

dnu publish --runtime <active/runtime name> [--no-source]

The --no-source option compiles everything and increases the startup time but removes the ability to change the code in the container.



来源:https://stackoverflow.com/questions/36000161/docker-container-with-asp-net-core-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!