我在使用Windows的docker获取运行iis / php环境时遇到一些问题。实际上有很多问题,但是让我们从这个开始:)
我的机器是Windows 10 Pro周年纪念日,而容器是基于WindowsCore的。
我有一个powershell命令,如果我在容器中运行,将更新默认文档,但无法从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.'
但是,在容器内,以下命令可以正常运行:
Get-IISConfigSection -SectionPath "system.webServer/defaultDocument" | Get-IISConfigCollection -CollectionName "files" | New-IISConfigCollectionElement -ConfigAttribute @{"Value" = "index2.php"}
此命令的相关问题:
Add-WebConfigurationProperty -Filter "//defaultDocument/files" -PSPath "IIS:\sites\mysite" -AtIndex 0 -Name "Collection" -Value "index2.php"
它可以在我的主机上正常工作,但不能在容器中工作,也不能在DockerFile中工作。
所以..
我需要在某个地方更新ps吗?
从DockerFile设置iis默认文档(第一个索引)的正确方法是什么。
谢谢
Docker版本信息:
> `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`
最佳答案
在对以下作品有所了解之后,有一些事情正在逃避:
RUN powershell.exe -Command " \
Import-module WebAdministration; \
Get-IISConfigSection -SectionPath system.webServer/defaultDocument | Get-IISConfigCollection -CollectionName files | New-IISConfigCollectionElement -ConfigAttribute @{'Value' = 'index2.php'} "
关于powershell - Docker Windows容器-DockerFile设置IIS默认文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40427634/