[英]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.