error when trying to create a php8 iis nano-server docker image

121 views Asked by At

i am trying to create a nanoserver-iis-php8 docker image. when copying the instructions in php site to a docker file like this line RUN powershell -command c:\windows\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI /+[fullPath='c:\php\php-cgi.exe'] i get this error message when building the image:

ERROR ( message:Malformed collection indexer; format is [@position,name='value',name2='value2',...]. The @position specifier is optional, and be '@start', '@end', or '@N' where N is a numeric index into the collection. )

how do i fix this?

1

There are 1 answers

2
samwu On

You can also try using the C# code:

using (ServerManager serverManager = new ServerManager())
  {
     Configuration config = serverManager.GetApplicationHostConfiguration();

     ConfigurationSection fastCgiSection = config.GetSection("system.webServer/fastCgi");
     ConfigurationElementCollection fastCgiCollection = fastCgiSection.GetCollection();
     ConfigurationElement applicationElement = fastCgiCollection.CreateElement("application");
     applicationElement["fullPath"] = @"C:\PHP\php-cgi.exe";
     serverManager.CommitChanges();
  }