简体   繁体   English

如何通过docker通过启动配置文件运行.net核心应用程序

[英]How to run .net core application with launch profile via docker

I am using Docker to deploy my ASP.NET Core app to a Linux machine. 我正在使用Docker将我的ASP.NET Core应用程序部署到Linux计算机上。 I have a pretty much default Dockerfile that looks like this: 我有一个非常像这样的默认Dockerfile:

FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "aspnetapp.dll"]

So my point is to be able to build & run different instances of a project with different settings and different launch profiles declared in launchsettings.json . 因此,我的观点是,能够使用launchsettings.json声明的不同设置和不同启动配置文件来构建和运行项目的不同实例。 For that I need to use different dockerfiles but there is a question: How do I setup a launch profile? 为此,我需要使用不同的dockerfile,但是有一个问题: 如何设置启动配置文件?

Docker uses ENTRYPOINT ["dotnet", "aspnetapp.dll"] to launch the app (which seems to be the right thing to do). Docker使用ENTRYPOINT ["dotnet", "aspnetapp.dll"]启动应用程序(这似乎是正确的选择)。 This string means dotnet command will be executed and according to doumentation seems that there's no way to pass launch profile as argument. 该字符串表示将执行dotnet命令,并且根据重复说明,似乎没有办法将启动概要文件作为参数传递。

Yes, I know that dotnet run command allows to pass it via --launch-profile <NAME> . 是的,我知道dotnet run命令允许通过--launch-profile <NAME>传递它。 But docs say it's not recommended to use just dotnet run and suggest to publish the app the way it's done in the Dockerfile 但是文档说,不建议仅使用dotnet run并建议以Dockerfile中的方式发布应用程序

What is the right thing to do here? 在这里做什么正确的事?

Thanks! 谢谢!

One possible way is to explicitly set all the different environment variables that the launchSettings includes in the Dockerfile . 一种可能的方法是显式设置launchSettings包含在Dockerfile中的所有不同环境变量。 Do you have things other than environmentVariables in the launchSettings.json ? launchSettings.json中,您是否拥有除了environmentVariables之外的其他launchSettings.json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 docker 容器中运行 asp.net 核心应用程序? - How to run an asp.net core application in docker container? 在 Linux Docker 中使用 .Net 标准库运行.Net Core 应用程序 - Run .Net Core application with .Net Standard library in Linux Docker 在Mac上配置.net核心应用程序? - Profile a .net core application on mac? Docker:“成功”docker 运行后无法在浏览器上启动 .Net Core 3 Api - Docker: Cannot launch .Net Core 3 Api on browser after "successful" docker run Docker:无法启动 ASP.Net Core 5 Web Api 在浏览器上运行 Z05B6053C41A2B130EAD 后 - Docker: Cannot launch ASP.Net Core 5 Web Api on browser after docker run Docker如何构建.Net核心应用? - How to build .Net core application in Docker? .NET Core如何指定运行应用程序的环境 - .NET Core how to specify environment to run application in 如何在 Docker 中运行 .NET Core 3.1.3 x86 应用程序 - How to run a .NET Core 3.1.3 x86 App in Docker 如何在 ASP.NET Core 应用程序中的 Docker 上正确安装证书? - How to properly install certificates on Docker in ASP.NET Core application? .NET Core API:通过 Docker 运行时“本地主机拒绝连接” - .NET Core API: "local host refused to connect " when run via Docker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM