【发布时间】:2019-01-06 09:19:03
【问题描述】:
我正在 Windows 2016 服务器上使用 docker 构建 ASP.NET Web API 应用程序。
这就是我的 dockerfile 的样子:
FROM microsoft/dotnet-framework:4.7.2-sdk AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.sln .
COPY TestWebAPI/*.csproj ./TestWebAPI/
COPY TestWebAPI/*.config ./TestWebAPI/
RUN nuget restore
# copy everything else and build app
COPY TestWebAPI/. ./TestWebAPI/
WORKDIR /app/TestWebAPI
RUN msbuild /p:Configuration=Release
FROM microsoft/iis:10.0.14393.206
SHELL ["powershell"]
FROM microsoft/aspnet:4.7.2 AS runtime
WORKDIR /inetpub/wwwroot
COPY --from=build /app/TestWebAPI/. ./
RUN Remove-Website -Name 'Default Web Site'
RUN New-Website -Name 'TestWebApi' -Port 80 \
-PhysicalPath 'c:\inetpub\wwwroot' -ApplicationPool '.NET v4.5'
EXPOSE 80
CMD Write-Host IIS Started... ; \
while ($true) { Start-Sleep -Seconds 3600 }
然后我执行以下命令来构建和运行容器:
docker image build --tag testwebapi --file .\Dockerfile .
docker container run --detach --publish 80 testwebapi
然后我使用容器的沙箱 id 运行 docker inspect:
docker inspect 5638e
它显示了我有关容器的信息,但 IP 地址列键为空。 我如何才能找到 IP 地址以及这里有什么问题?
【问题讨论】:
标签: .net docker dockerfile devops docker-container