Docker Windows容器 - DockerFile设置iis默认文档

时间:2016-11-04 16:34:00

标签: powershell docker dockerfile

我在使用docker for windows获取正在运行的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'未被识别为内部或外部   命令,可操作程序或批处理文件。'

但是,在容器内部,以下命令可以正常工作:

 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`

1 个答案:

答案 0 :(得分:1)

在对以下作品进行一些调整之后,有一些事情正在逃避:

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