(1)针对NerdDinner应用的Dockerfile内容如下
PS E:DockeronWindowsChapter02ch02-nerd-dinner> cat .Dockerfile
# escape=`
FROM sixeyed/msbuild:netfx-4.5.2-webdeploy-10.0.14393.1198 AS builderWORKDIR C:srcNerdDinner
COPY srcNerdDinnerpackages.config .
RUN nuget restore packages.config -PackagesDirectory ..packagesCOPY src C:src
RUN msbuild NerdDinner.csproj /p:OutputPath=c:outNerdDinner `
/p:DeployOnBuild=true /p:VSToolsPath=C:MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3 oolsVSToolsPath# app image
FROM microsoft/aspnet:windowsservercore-10.0.14393.1198
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]ENV BING_MAPS_KEY bing_maps_key
WORKDIR C: erd-dinnerRUN Remove-Website -Name 'Default Web Site'; `
New-Website -Name 'nerd-dinner' `
-Port 80 -PhysicalPath 'c: erd-dinner' `
-ApplicationPool '.NET v4.5'RUN & c:windowssystem32inetsrvappcmd.exe `
unlock config `
/section:system.webServer/handlersCOPY --from=builder C:outNerdDinner\_PublishedWebsitesNerdDinner C: erd-dinner
(2)进行构建镜像
PS E:DockeronWindowsChapter02ch02-nerd-dinner> docker container run -d -P dockeronwindows/ch02-nerd-dinner
(3)通过docker container inspect获得容器的IP地址
(4)访问服务应该如下所示:
docker container run -d -P dockeronwindows/ch02-nerd-dinner