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

标签 powershell docker dockerfile

我在使用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/

相关文章:

bash - 如何进入这个 dockerfile/nginx 容器?

docker 无法挂载 linux 目标/

docker - 无法将服务器上的 docker 应用程序暴露给外部 IP

docker - 在 “docker run”时间覆盖Dockerfile覆盖环境变量

docker - 如何禁用 CGO 以运行测试

powershell - VS Code - Powershell 模块 - 命令无法识别

Powershell 网页自动化适用于 Internet,而非 Intranet

powershell - 以目录名称YYYY-MM-DD的格式获取目录中带有.JPG扩展名的文件

docker - 如何在Docker机器上安装apt?

regex - 从变量中搜索字符串并仅打印其上方的 3 行