docker - 在docker上发布一个基于asp.net core RC2的web api

标签 docker .net-core-rc2

我正在尝试基于docker在docker上发布一个web api。

我正在使用具有以下内容的 docker 文件:

FROM microsoft/dotnet
COPY . /dotnetapp
WORKDIR /dotnetapp
RUN dotnet restore
EXPOSE 5000
ENTRYPOINT dotnet run

我可以构建和运行图像,但我无法访问 web api。

最佳答案

似乎您必须指定 Kestrel 将监听的 URL,否则它将不接受同一容器之外的任何连接。

所以你的入口点应该是这样的

ENTRYPOINT ["dotnet", "run", "--server.urls=http://0.0.0.0:5000"]

Including the –server.urls argument is vital to allow inbound connections from outside container. If not, Kestrel will reject any connection that is not coming from the container, something not really useful…



引用 https://www.sesispla.net/blog/language/en/2016/05/running-asp-net-core-1-0-rc2-in-docker/

关于docker - 在docker上发布一个基于asp.net core RC2的web api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37678182/

相关文章:

Docker-compose 从 env 文件指定标签

asp.net - 带有Linux Docker自动生成的 “Service '的ASP.NET无法构建:COPY失败:stat/var/lib/docker/tmp/docker-builder”

.net - 找不到 Razor 模板

c# - 如何将文件作为链接添加到 .NET Core 库中?

asp.net-core - 在 ASP.NET Core 应用程序 (RC2) 中使用 net451 库

c# - 如何使用 ASP.NET Core RC2 MVC6 和 IIS7 获取当前 Windows 用户

c# - 在 docker 容器中连接到 SQL Server 时出错

bash - 如何在 docker 中使用 bash 作为 PID1 重现僵尸进程?

docker - 如何限制从 docker 容器上传的速率?

c# - AspNet Core RC2 模型绑定(bind)给出空模型