【发布时间】:2020-12-26 21:09:35
【问题描述】:
我有 .net core 3.1 dockerized 及更高版本 (docker-compose up --build) 来自 docker 容器,但我仍然无法使用 http://localhost:8080/ 或 http://127.0.0.1:8080/ 从应用程序访问任何招摇网址
launchSettings.json
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"MyApp.API": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://0.0.0.0:5001;http://0.0.0.0:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
Dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:3.1
WORKDIR /home/app
Copy ... projedct files ommited on purpose for clarity ...
RUN dotnet restore
COPY . .
RUN dotnet publish MyApp.API/MyApp.API.csproj -o /publish/
WORKDIR /publish
ENV ASPNETCORE_URLS=https://+:5001;http://+:5000
ENTRYPOINT ["dotnet", "MyApp.API.dll"]
docker-compose.yml
version: '3.0'
services:
api:
ports:
- "8080:5000"
- "8081:5001"
build:
context: .
dockerfile: MyApp.API/Dockerfile
image: myapp/api:runtime
【问题讨论】:
-
你没有暴露端口 5000 和 5001
-
尝试
EXPOSE容器中的端口