【发布时间】:2021-04-11 10:27:58
【问题描述】:
我正在努力让我的 docker 容器在 localhost 上侦听(不断获取站点无法访问)。我遵循了有关 jetbrains 的官方指南以及我在网上找到的其他一些指南,但仍然没有运气。
在我的本地开发中,我希望我的 Web API 容器和 Postgres 容器能够相互通信,但是当它们上线时,它们将与 en RDS 实例通信
Docker 文件
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS base
WORKDIR /app
EXPOSE 8080
ENV ASPNETCORE_URLS=http://+:8080
# Copy csproj and restore as distinct layers
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY . .
RUN dotnet restore "api/api.csproj"
WORKDIR "/src/api"
RUN dotnet build "api.csproj" -c Release -o /app
FROM build AS publish
WORKDIR "/src/api"
RUN dotnet publish "api.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "api.dll", "--urls", "http://*:8080"]
启动设置
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:14317",
"sslPort": 44301
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"wander.api": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "",
"applicationUrl": "https://localhost:8081;http://localhost:8080",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
【问题讨论】: