You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker卷绑定引发IIS 401.3错误的技术求助

基于IIS的Docker本地开发环境异常问题

问题现象

  • 首次加载网站正常,数次刷新后触发401.3错误,等待约30秒后刷新可恢复正常
  • 直接访问localhost会直接返回401.3,必须使用localhost/index.php这类带具体文件名的URL才能访问

对比验证

改用Dockerfile中的COPY ./data C:\inetpub\wwwroot命令部署代码后,网站运行完全正常,无上述异常。

排查结果

检查访问控制列表(ACL)发现:docker-compose卷绑定方式生成的文件/文件夹ACL与COPY命令生成的不一致,且受Docker限制无法修改卷内资源的ACL。

已尝试的解决方案

使用非默认应用程序池和网站配置,问题未得到解决。

当前环境配置

  • 基础镜像:windows/servercore:ltsc2019
  • IIS配置命令:
RUN powershell -Command `
    Add-WindowsFeature Web-Server, Web-Http-Redirect, Web-Http-Tracing, Web-Dyn-Compression, Web-Windows-Auth, Web-Asp, NET-Framework-45-ASPNET, NET-WCF-HTTP-Activation45, Web-Asp-Net45; `
    Invoke-WebRequest -UseBasicParsing -Uri "https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.10/ServiceMonitor.exe" -OutFile "C:\ServiceMonitor.exe"

RUN dism.exe /Online /Enable-Feature /FeatureName:IIS-CGI /All && `
    %windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/fastCgi /+[fullPath='c:\PHP\php-cgi.exe'] && `
    %windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='c:\PHP\php-cgi.exe',resourceType='Either'] && `
    %windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /[fullPath='c:\PHP\php-cgi.exe'].instanceMaxRequests:10000 && `
    %windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+[fullPath='c:\PHP\php-cgi.exe'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000'] && `
    %windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+[fullPath='c:\PHP\php-cgi.exe'].environmentVariables.[name='PHPRC',value='C:\PHP'] && `
    %windir%\system32\inetsrv\appcmd.exe set config /section:defaultDocument /enabled:true /+files.[value='index.php'] && `
    setx PATH /M %PATH%;C:\PHP && `
    setx PHP /M "C:\PHP" && `
    del C:\inetpub\wwwroot\* /Q
  • docker-compose卷配置:
volumes:
    -  type: bind
       source: ./data
       target: C:\inetpub\wwwroot

内容的提问来源于stack exchange,提问作者Bjorge

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 19:42:48