Docker volume bind results in IIS 401.3 error

48 Views Asked by At

I am trying to setup a local development environment with IIS for hosting and I get some wierd behaviour. The initial load of the website works, but a few refreshes results in 401.3. After like 30 seconds I can then refresh the page again and it works. Also, URL's like localhost does not work and goes straight to 401.3 and I have to use localhost/index.php for example.

If I instead uses the command COPY ./data C:\inetpub\wwwroot the website works flawlesly. I also checked the access control list and was wondering if that was the issue. Using the volume bind via docker-compose results in different ACL than using COPY command in the Dockerfile. The files and folders from the volume cannot be changed as Docker does not allow to change ACL on files and folders that are part of the volume.

I have also tried using different application pool and website than the default ones, but the result is the same.

I am currently using the base windows/servercore:ltsc2019 image and are using the following setup for 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

The docker-compose file consits of a single service with a volume defined as:

volumes:
    -  type: bind
       source: ./data
       target: C:\inetpub\wwwroot
0

There are 0 best solutions below