本文主要是介绍DotNet Core 在Centos上使用环境变量运行 urls 参数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
dotnet 程序指定 url参数运行,通过参数绑定端口运行
使用 export 来设置
export ASPNETCORE_URLS=http://*:8867
export ASPNETCORE_ENVIRONMENT=Development
示例如下:
[root@ecs-242e-0002 Cwcs.Cloud.Manager]# export ASPNETCORE_URLS=http://*:21867[root@ecs-242e-0002 Cwcs.Cloud.Manager]# export ASPNETCORE_ENVIRONMENT=Development[root@ecs-242e-0002 Cwcs.Cloud.Manager]# dotnet
[root@ecs-242e-0002 Cwcs.Cloud.Manager]# dotnet XXX.dll
Dockerfile设置 dotnet 的环境变更 用ENV
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.#FROM microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-sac2016 AS base#FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base 这个不知道为什么不行运行的时候提示#It was not possible to find any compatible framework version#The framework 'Microsoft.AspNetCore.App', version '5.0.0' was not found.#- No frameworks were found.##You can resolve the problem by installing the specified framework and/or SDK.##The specified framework can be found at:#- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=5.0.0&arch=arm64&rid=debian.10-arm64#FROM mcr.microsoft.com/dotnet/aspnet:5.0 #用这个就可以了FROM mcr.microsoft.com/dotnet/sdk:5.0 AS baseWORKDIR /appEXPOSE 15566EXPOSE 25001COPY . .ENV ASPNETCORE_ENVIRONMENT=DevelopmentENV ASPNETCORE_URLS=http://*:25001ENTRYPOINT ["dotnet", "XXX.dll"]
Dotnet coer 设置命令行
dotnet AspNetCoreUrl.dll --urls "http://localhost:7001;https://localhost:7011"
这篇关于DotNet Core 在Centos上使用环境变量运行 urls 参数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!