我正在尝试基于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/