docker微软/ iis卷

我试图附加一个卷到docker集装箱,但没有任何我尝试的方式工作。 我正在使用Azure Windows 2016 vm这里的泊坞窗信息:

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.config。

起初,我试图在dockerfile中成功build立VOLUME / inetpub,但是当我运行容器时,它给了我下面的错误。

在CreateContainer中遇到错误:Windows系统调用失败:该目录不是空的

但是在docker文档中没有提到需要清空的卷。

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

我尝试的最后一件事是与docker合成,在我的服务,我有卷: – ./inetpub:/inetpub给出以下错误

无法为服务创build容器wfgen:无效的卷规格“/ inetpub”:无效的卷规范

我尝试了许多变种 – ./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 run –rm -vc:/ folder:c:/ somefolder microsoft / iis

它可以完美的工作,我可以创build文件,我可以删除它们等。docker信息:C:\ Users \ core>docker信息

 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 

我正在使用dockertesting版。

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

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

然后,我只是发出docker run --rm -d -p 8000:80 -vc:/Logs:c:/inetpub/wwwroot/Portals/Logs --name site-v my-image-name从这里得到的信息。