我试图将一个卷附加到docker容器,但我试过的方法都没有。我正在使用Azure Windows 2016虚拟机 这里的码头信息:
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中尝试了VOLUME / inetpub,但是当我运行容器时,它给了我以下错误。
在CreateContainer期间遇到错误:Windows系统调用失败:目录不为空
但是在docker文档中没有提到任何需要为空的卷。
然后我尝试在运行时附加卷,例如,docker run -p 80:80 -v C:/ build / inetpub:C:/ inetpub web / iis。 这给了我同样的错误。但是当我尝试着 docker run -p 80:80 -v C:/ build / inetpub:C:/ randomtest web / iis。 它有效,但我无法修改容器停止的文件。
我尝试的最后一件事是使用docker-compose, 在我的服务中我有 卷: - ./inetpub:/inetpub 出现以下错误
无法为服务wfgen创建容器:无效的卷规范“/ inetpub”:无效的卷规范
我尝试了很多变种 - ./inetpub:/inetpub,但他们总是给我同样的错误。
感谢您的帮助,我已经坚持了好几天没有任何结果。
这是我的泊坞文件
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
答案 0 :(得分:0)
所以我刚尝试过这个:
docker run --rm -v c:/ folder:c:/ somefolder microsoft / iis
它完美无缺,我可以创建文件,我可以删除它们等。 码头信息: C:\ Users \ core> docker info
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
我正在使用docker beta。
答案 1 :(得分:0)
这是因为目前windows容器只支持空目录。我只需映射日志卷,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
从here获得了信息。