DotNet Core 在Centos上使用环境变量运行 urls 参数

2023-12-21 15:48:27

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 base

WORKDIR /app

EXPOSE 15566

EXPOSE 25001

COPY . .

ENV ASPNETCORE_ENVIRONMENT=Development

ENV ASPNETCORE_URLS=http://*:25001

ENTRYPOINT ["dotnet", "XXX.dll"]

Dotnet coer 设置命令行

dotnet AspNetCoreUrl.dll --urls "http://localhost:7001;https://localhost:7011"

文章来源:https://blog.csdn.net/daonidedie/article/details/135130646
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。