1
votes

I am having some issues getting a running iis/php environment using docker for windows. In fact lots of issues, but lets start with this one :)

My machine is Windows 10 Pro anniversary, and the container, is a WindowsCore based.

I have a powershell command that if I run inside the container will update the default document, but doesnt work from the DockerFile.

RUN powershell.exe -Command \
    Import-module IISAdministration; \
    Get-IISConfigSection -SectionPath "system.webServer/defaultDocument" | Get-IISConfigCollection -CollectionName "files" | New-IISConfigCollectionElement -ConfigAttribute @{"Value" = "index2.php"}

'Get-IISConfigCollection' is not recognized as an internal or external command, operable program or batch file.'

However, inside the container the following command works fine :

 Get-IISConfigSection -SectionPath "system.webServer/defaultDocument" | Get-IISConfigCollection -CollectionName "files" | New-IISConfigCollectionElement -ConfigAttribute @{"Value" = "index2.php"}

Related issue with this command :

Add-WebConfigurationProperty -Filter "//defaultDocument/files" -PSPath "IIS:\sites\mysite" -AtIndex 0 -Name "Collection" -Value "index2.php"

It works fine on my host but not in the container, and not in the DockerFile.

So ..

Do I need to update ps somewhere?

What would be the correct way to set iis default document (first index), from the DockerFile.

Thanks

Docker version info:

> `PS E:\Docker> docker version
Client:
 Version:      1.13.0-dev
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   16bcc1a
 Built:        Fri Nov  4 08:04:41 2016
 OS/Arch:      windows/amd64

Server:
 Version:      1.13.0-dev
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   16bcc1a
 Built:        Fri Nov  4 08:04:41 2016
 OS/Arch:      windows/amd64
 Experimental: false`
1

1 Answers

1
votes

There is something going on with escaping, after some fiddling about the following works:

RUN powershell.exe -Command  " \
Import-module WebAdministration; \
Get-IISConfigSection -SectionPath system.webServer/defaultDocument | Get-IISConfigCollection -CollectionName files | New-IISConfigCollectionElement -ConfigAttribute @{'Value' = 'index2.php'} "