【问题标题】:Docker Windows Container - DockerFile set iis default documentDocker Windows Container - DockerFile 设置 iis 默认文档
【发布时间】:2023-03-11 02:14:01
【问题描述】:

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

【问题讨论】:

    标签: powershell docker dockerfile


    【解决方案1】:

    在对以下工作进行了一些摆弄之后,转义发生了一些事情:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-05
      • 2018-04-21
      • 2011-07-08
      • 2011-06-02
      • 2015-05-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多