3

我在我的 中使用以下脚本创建了一个图像Dockerfile,但是当我使用容器的 IP 地址和端口(2000)浏览时,我得到一个 403 - Forbidden: Access is denied。我正在使用 Windows 10.0.14393 Build 14393, Docker Desktop for Windows。该项目是一个包含 Nancy、Entity Framework、AngularJS 和 SQL Server 项目的 ASP.NET 解决方案。我是否需要对我的 IIS、Docker、Powershell 等进行任何配置更改?我的 Dockerfile 脚本是:

FROM microsoft/aspnet:windowsservercore
# using powershell commands
SHELL ["powershell"]

# location of the source directory
WORKDIR C:/src/Project


# run project using port 2000
RUN Remove-Website -Name 'Default Web Site'; \
    New-Website -Name 'Project' -Port 2000 -PhysicalPath 'C:/src/Project'
4

2 回答 2

1
  1. 确保您的文件不会在 .dockerignore 中被忽略

  2. 复制这个 Dockerfile

FROM microsoft/aspnet
WORKDIR /inetpub/wwwroot
COPY . /inetpub/wwwroot
# Give Full Access To Folder
RUN icacls 'c:/inetpub/wwwroot' /grant 'Everyone:(OI)(CI)F'
# Check that the files have been successfully copied
RUN dir 
  1. 泊坞窗构建 -t 测试。
  2. docker run -p 8001:80 测试
于 2019-11-08T17:06:35.583 回答
-1

不幸的是,它可能有很多事情......我遇到了同样的问题,问题是/inetpub/wwwroot文件夹是空的。我可以看到您正在添加一个新的网站文件夹,但您可以尝试:

我的码头文件是

# FROM microsoft/aspnet:4.7.1-windowsservercore-1709
FROM microsoft/aspnet:4.7.1-windowsservercore-ltsc2016
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} /inetpub/wwwroot

您也可以尝试这里提出的解决方案: https ://github.com/Microsoft/iis-docker/issues/5

干杯!

编辑:我在使用 localhost 或 127.0.0.1 时也遇到了问题。使用公共 IP 地址

于 2018-10-10T11:10:55.153 回答