Docker Windows容器 403 - Forbidden: Access is Denied。

4
我已经在我的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'

我也遇到了同样的错误。 - KatariaA
嘿,你找到任何解决方案了吗? - David Bensoussan
我遇到了同样的问题,但没有解决方案。 - Matt Drouillard
2个回答

2
  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. docker build -t test .
  2. docker run -p 8001:80 test

-1

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

我的 Docker 文件是

# 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地址。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接