为什么 docker 在 IIS 上更改源代码后会出现 http 403 错误?

Why docker on IIS gives http 403 error after source code change?

我可以成功构建和 运行 一个演示经典 asp 站点 (此处给出:https://www.docker.com/blog/get-apps-off-windows-2003-cloud-docker-enterprise/) (源代码在这里:https://github.com/sixeyed/presentations/tree/master/docker-webinars/from-w2k3-to-cloud)与以下 Dockerfile:

# escape=`
FROM microsoft/iis:windowsservercore-ltsc2016
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN Install-WindowsFeature Web-ASP
COPY ./share/ClassicAspApp.zip .

RUN Expand-Archive -Path ClassicAspApp.zip -DestinationPath C:\ClassicAspApp; `
    Remove-Item ClassicAspApp.zip

RUN Remove-Website -Name 'Default Web Site'; `
    New-Website -Name web-app -Port 80 -PhysicalPath C:\ClassicAspApp

构建镜像后(docker image build -t sixeyed/w2k3-classic-asp -f .\docker\classic-asp\Dockerfile .)和运行安装容器(docker容器运行 -d sixeyed/w2k3-classic-asp) 然后浏览到特定的 url(发现者:docker container inspect)我确实可以获得经典的 asp 站点作为预期。

但是,每当我解压缩并更改(甚至一点)演示 asp 文件(在共享文件夹中)中的源代码,然后重新构建图像和 运行 容器时,浏览到 url,我总会遇到 http 403 - Forbidden: Access is denied。您无权使用您提供的凭据查看此目录或页面。

我已尝试从许多来源(例如 IIS in Docker returning 403 and )找到此问题的解决方案,但到目前为止没有成功。

谁能弄明白为什么我在更改源代码中的测试asp-文件时总是遇到http 403?那么,应该如何解决这个问题?

我想我自己找到了解决方案——虽然我真的还不知道为什么更改演示项目的源代码实际上会导致 403 错误。但是,在检查这个问题时,我在另一个目录中创建了一个新的简单经典 asp -project 并使 Dockerfile 适应这些路径变化,如下所示:

# escape=`
FROM microsoft/iis:windowsservercore-ltsc2016
SHELL ["powershell", "-Command"]
RUN Install-WindowsFeature Web-ASP
RUN mkdir C:\testAsp
COPY ./code/asp/ C:\testAsp
RUN Remove-Website -Name 'Default Web Site'; `
    New-Website -Name web-app -Port 8000 -PhysicalPath C:\testAsp

之后我仍然收到 http-403 错误。然后我发现了以下回复:403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied 突然意识到因为我的 asp-test 文件没有命名为 default.asp-file 服务器找不到它。所以,我的错误是由于相当幼稚和简单的原因——至少在第二个演示中是这样。

但是第一个演示项目中的 asp-file 确实是默认类型 (default.asp),因此我不确定为什么其中的任何更改都会将其变成 http- 403错误。可能是中间解压和压缩有关系,服务器找不到解压后的文件夹里面有asp-file.

但是,现在至少经典 asp 站点的基本对接工作了!