【问题标题】:cant access running container root and the image as well也无法访问正在运行的容器根目录和映像
【发布时间】:2021-03-25 07:28:52
【问题描述】:

enter image description here 我的 docker compose 文件似乎运行良好,在 docker 仪表板中我看到相应的容器正在工作。

当我转到 http://localhost:6001/ 时,我看到的只是一条错误消息,内容如下:

'此页面无法正常工作。 localhost 没有发送任何数据。 ERR_EMPTY_RESPONSE'。

我不知道如何解决这个问题。我在某处看到将 localhost 替换为“0.0.0.0”,但不确定如何在这种情况下执行此操作,我觉得我已经看到它与 localhost 一起使用,所以我不确定如何处理这些信息。

我检查了其他来源,看看我做错了什么,但没有找到好的解决方案。我很想就这个问题寻求任何建议!

我的Dockerfile

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat

FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["TestDocker.csproj", "."]
RUN dotnet restore "./TestDocker.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "TestDocker.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "TestDocker.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TestDocker.dll"]

enter image description here

【问题讨论】:

  • 您实际上是如何启动容器的?您在问题中附加了哪些图片?
  • 我尝试了这两种方法 - 从 docker 桌面工具和 docker run -p 6001:8080 命令(浏览 localhost:6001 端口)以及。没有运气

标签: docker dockerfile containers


【解决方案1】:

尝试使用 127.0.0.1 而不是 localhost 进行访问。

【讨论】:

  • 还是一样,不工作我尝试使用 - 127.0.0.1:6001/weatherforecast - 响应是无法访问此站点127.0.0.1 响应时间太长。尝试:检查连接检查代理和防火墙运行 Windows 网络诊断 ERR_CONNECTION_TIMED_OUT
  • 嗨 Raghu,你能分享我的 .Net 5.0 用于 asp.netcore webapi 模板的示例 docker 文件吗?
猜你喜欢
  • 2019-10-21
  • 2020-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-06
  • 2019-04-20
  • 1970-01-01
  • 2022-10-06
相关资源
最近更新 更多