在dotnet SDK和Docker容器上(On dotnet SDK and Docker containers)

编程入门 行业动态 更新时间:2024-10-25 17:16:14
在dotnet SDK和Docker容器上(On dotnet SDK and Docker containers)

这个问题应该是非常直截了当的。

假设您正在尝试运行Asp.Net Core Web Api。 该应用程序将在Linux的干净安装中的Docker容器内运行(味道并不重要)。 容器位于Kubernetes集群中的POD内,该集群带有docker工具。

Dockerfile需要针对特定​​版本的aspnetcore,看起来像这样:

FROM microsoft/aspnetcore:1.1 COPY . /app WORKDIR /app EXPOSE 5000/tcp ENV ASPNETCORE_URLS http://*:5000 ENTRYPOINT ["dotnet", "run"]

测试一下,我运行一个Docker命令就是这样......

所以我难倒的是这个; 我假设ENTRYPOINT定义中的“dotnet”命令正在运行.Net Core SDK。

如果此Linux代理上的容器没有安装SDK,或者安装的SDK是您尝试使用的SDK的旧版本,那么您将如何获得此版本的docker? 本质上,ENTRYPOINT中的“dotnet”命令指的是一个不存在的程序?

我是否应该将SDK与容器打包在一起? 如果是这样,该行是否应该读取ENTRYPOINT [“./dotnet”,“run”]因为它在Linux上? 如果是这样,我还需要执行哪些其他步骤才能打包SDK?

我的假设是SDK已经在microsoft / aspnetcore:1.1的容器中打包了? 如果是这样,有没有办法在ENTRYPOINT定义中引用打包的可执行文件?

任何见解将不胜感激!

This question should hopefully be pretty straight forward.

Say you're trying to run an Asp.Net Core Web Api. The app will run inside of a Docker container inside a clean installation of Linux (flavor doesn't really matter). The container lives inside a POD in a Kubernetes cluster which comes with docker tools.

The Dockerfile needs to target a specific version of aspnetcore and looks something like this:

FROM microsoft/aspnetcore:1.1 COPY . /app WORKDIR /app EXPOSE 5000/tcp ENV ASPNETCORE_URLS http://*:5000 ENTRYPOINT ["dotnet", "run"]

Testing things out, I run a Docker command as so...

So what I'm stumped on is this; that "dotnet" command in the ENTRYPOINT definition I'm assuming is running the .Net Core SDK.

If the container on this Linux agent does not have the SDK installed, or the SDK that is installed is an older version that the SDK that you're trying to use, how exactly would you get this to docker build? Essentially that "dotnet" command in the ENTRYPOINT is referring to a program that doesn't exist?

Am I supposed to package the SDK with the container as well? If so, should that line read ENTRYPOINT ["./dotnet", "run"] because it's on Linux? Also if so, what other steps do I need to perform to package the SDK?

My assumption was that the SDK is packaged already in the container with microsoft/aspnetcore:1.1? If so, is there a way to reference the packged executable in the ENTRYPOINT definition?

Any insight would be greatly appreciated!

最满意答案

如果你需要SDK,我想你想要https://hub.docker.com/r/microsoft/aspnetcore-build/ 。

您正在使用的图像仅包括运行时,而不包括SDK。

If you need the SDK, I think you want https://hub.docker.com/r/microsoft/aspnetcore-build/.

The image you're using includes just the runtime, not the SDK.

更多推荐

本文发布于:2023-07-31 01:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340446.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容器   SDK   dotnet   containers   Docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!