使用docker microsoft/iis的卷

本文关键字:iis 的卷 microsoft docker 使用 | 更新日期: 2023-09-27 18:14:48

我试图将卷附加到docker容器,但我尝试的方法都不起作用。我正在使用Azure Windows 2016虚拟机这里是docker信息:

Containers: 2
Running: 1
Paused: 0
Stopped: 1
Images: 108
Server Version: 1.12.2-cs2-ws-beta
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: nat null overlay
Swarm: inactive
Default Isolation: process
Kernel Version: 10.0 14393 (14393.321.amd64fre.rs1_release_inmarket.161004-2338)
Operating System: Windows Server 2016 Datacenter
OSType: windows
Architecture: x86_64
CPUs: 2
Total Memory: 7 GiB
Name: wfgendocker
ID: QBKJ:RZAU:ADAI:WS4U:JV2K:IB5I:52K6:MWTD:NS3X:KRP6:SH6T:QKDT
Docker Root Dir: C:'ProgramData'docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

所以在我的docker文件中,我将我的IIS网站复制到inetpub/root我的目标是将容器上的/inetpub挂载到本地机器上,以便更改脚本和web。配置可以在运行时完成。

起初我尝试在dockerfile中成功构建VOLUME/inetpub,但是当我运行容器时,它给了我以下错误。

在CreateContainer过程中遇到错误:Windows系统调用失败:目录不为空

但是docker文档中没有任何地方提到卷需要为空。

所以我试着在运行时附加卷,例如,docker运行-p 80:80 -v C:/build/inetpub:C:/inetpub web/iis。这给了我和上面一样的错误。但当我尝试
docker运行-p 80:80 -v C:/build/inetpub:C:/randomtest web/iis。它工作,但我不能修改文件,否则容器停止。

我尝试的最后一件事是使用docker-compose,在我的服务中,我有卷:-/inetpub:/inetpub这会产生以下错误

不能为服务创建容器wfgen: invalid volume spec "/inetpub": invalid volume specification

我尝试了许多不同的- ./inetpub:/inetpub,但他们总是给我相同的错误。

谢谢你的帮助,我已经坚持了几天没有任何结果。

这是我的docker文件

FROM microsoft/iis:10.0.14393.206
SHELL ["powershell"]
#adding windows features to vm
RUN Install-WindowsFeature NET-Framework-45-ASPNET ; '
    Install-WindowsFeature Web-Asp-Net45
#temp tempfile
RUN mkdir C:'temp
#adding wfgen_admin user to vm
RUN mkdir C:'createUser
COPY createUser/ /createUser
RUN createUser/wfgen_adminCreate.ps1
#installing the services and starting them
RUN mkdir C:'aprogramfiles
COPY wfgenServices/ /aprogramfiles
RUN aprogramfiles/.'winsvc-install.cmd
#copying wfgen webcontent to vm
COPY inetpub/wwwroot/ /inetpub/wwwroot
RUN createUser/wfgen_admin_grant_access.ps1
#removing default website that runs on port 80
RUN Remove-WebSite -Name 'Default Web Site'
#creating a new iis website with the copied wfgen website i am not sure if i have the right commands here
RUN powershell -NoProfile -Command '
        Import-module IISAdministration; '
    New-IISSite -Name "wfgenroot" -PhysicalPath C:'inetpub'wwwroot -   BindingInformation "*:80:";
    #converting weforms and ws to applications
RUN ConvertTo-WebApplication "IIS:/Sites/wfgenroot/wfgen";
RUN ConvertTo-WebApplication "IIS:/Sites/wfgenroot/wfgen/WfApps/WebForms";
RUN ConvertTo-WebApplication "IIS:/Sites/wfgenroot/wfgen/ws"
#Setting the authentication type of the website
RUN Set-WebConfiguration system.web/authentication 'IIS:/Sites/wfgenroot' -value @{mode='Windows'}
RUN Set-WebConfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -name enabled -value true -PSPath 'IIS:/Sites/wfgenroot/wfgen'
RUN New-SelfSignedCertificate -CertStoreLocation createUser -DnsName 127.0.0.1
RUN New-WebBinding -Name "wfgenroot" -IP "*" -Port 443 -Protocol https
RUN $Thumbprint = (Get-ChildItem -Path Microsoft.PowerShell.Security'Certificate::LocalMachine'My | Where-Object {$_.Subject -match "127.0.0.1"}).Thumbprint;
RUN get-item Microsoft.PowerShell.Security'Certificate::LocalMachine'My'$Thumbprint | new-item 0.0.0.0!443
#RUN createUser/appcmdrun.ps1
#exposing port 80
EXPOSE 80
EXPOSE 443
WORKDIR /inetpub

使用docker microsoft/iis的卷

我刚刚试过了:

docker run——rm -v c:/folder:c:/somefolder microsoft/iis

,它工作得很好,我可以创建文件,我可以删除它们,等等。码头工人信息:C:'Users'核心>码头工人信息

Containers: 2
 Running: 1
 Paused: 0
 Stopped: 1
Images: 6
Server Version: 1.12.2-cs2-ws-beta
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: nat null overlay transparent
Swarm: inactive
Security Options:
Kernel Version: 10.0 14393 (14393.321.amd64fre.rs1_release_inmarket.161004-2338)
Operating System: Windows 10 Enterprise
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 7.865 GiB
Name: pytop
ID: FENS:OO6R:J273:I5BB:2OGZ:HAMM:6YFX:53BP:XBA5:G3LE:QNKE:FLJ3
Docker Root Dir: C:'ProgramData'Docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
 127.0.0.0/8

这是因为目前窗口容器只支持空目录。我只需要映射日志卷,这个命令在Dockerfile中帮助了我:

RUN ["powershell", "Remove-Item", "C:''inetpub''wwwroot''Portals''Logs''*", "-Recurse"]

然后我简单地发行了docker run --rm -d -p 8000:80 -v c:/Logs:c:/inetpub/wwwroot/Portals/Logs --name site-v my-image-name从这里得到信息