简体   繁体   English

与docker microsoft / iis的卷

[英]Volumes with docker microsoft/iis

I was trying to attach a volume to the docker container but none of the ways I tried worked. 我试图将一个卷附加到docker容器,但我尝试的方法都没有。 I am working with an Azure Windows 2016 vm Here the docker info: 我正在使用Azure Windows 2016 vm这里的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

So in my docker file I am copying over my IIS website into inetpub/root and my goal is to mount /inetpub on the container to the local machine so changes to the scripts and web.config can be done at run time. 所以在我的docker文件中,我将我的IIS网站复制到inetpub / root中,我的目标是将容器上的/ inetpub挂载到本地机器,因此可以在运行时更改脚本和web.config。

At first I tried VOLUME /inetpub in the dockerfile which build successfully, but then when I ran the container, it give me the following error. 起初我在dockerfile中尝试了成功构建的VOLUME / inetpub,但是当我运行容器时,它给了我以下错误。

encountered an error during CreateContainer: failure in a Windows system call: The directory is not empty 在CreateContainer期间遇到错误:Windows系统调用失败:目录不为空

But there is no mention anywhere in the docker documentation about the volume needing to be empty. 但是在docker文档中没有提到任何需要为空的卷。

So then I tried attaching the volume at run, such as, docker run -p 80:80 -v C:/build/inetpub:C:/inetpub web/iis . 所以我尝试在运行时附加卷,例如,docker run -p 80:80 -v C:/ build / inetpub:C:/ inetpub web / iis。 this gave me the same error as above. 这给了我同样的错误。 but when i try 但是当我尝试
docker run -p 80:80 -v C:/build/inetpub:C:/randomtest web/iis . docker run -p 80:80 -v C:/ build / inetpub:C:/ randomtest web / iis。 it works, but I can't modify the files else the container stops. 它工作,但我无法修改容器停止的文件。

The last thing I tried was working with docker-compose, in my service I have volumes: - ./inetpub:/inetpub which give the following error 我尝试的最后一件事是使用docker-compose,在我的服务中我有卷: - ./inetpub:/inetpub,它给出了以下错误

Cannot create container for service wfgen: invalid volume spec "/inetpub": invalid volume specification 无法为服务wfgen创建容器:无效的卷规范“/ inetpub”:无效的卷规范

I tried many variations of - ./inetpub:/inetpub but they always gave me the same error. 我尝试了很多变种 - ./inetpub:/inetpub但是他们总是给我同样的错误。

Thanks for any help, I ve been stuck on this for days without any results. 感谢您的帮助,我已经坚持了好几天没有任何结果。

Here is my docker file 这是我的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

So I've just tried this: 所以我刚试过这个:

docker run --rm -vc:/folder:c:/somefolder microsoft/iis docker run --rm -vc:/ folder:c:/ somefolder microsoft / iis

and it works perfectly, I can create files, I can delete them, etc. docker info: C:\\Users\\core>docker info 它工作得很好,我可以创建文件,我可以删除它们等。泊坞信息: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

I'm using docker beta. 我正在使用docker beta。

This is because at the moment windows containers support only empty directories. 这是因为目前windows容器只支持空目录。 I needed to map only logs volume and this command in Dockerfile helped me: 我只需映射日志卷,Dockerfile中的这个命令帮助我:

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

Then I simply issued docker run --rm -d -p 8000:80 -vc:/Logs:c:/inetpub/wwwroot/Portals/Logs --name site-v my-image-name Got info from here . 然后我简单地发出了docker run --rm -d -p 8000:80 -vc:/Logs:c:/inetpub/wwwroot/Portals/Logs --name site-v my-image-name这里获取信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Visual Studio的Docker卷 - Docker volumes with Visual Studio 使用 Docker 卷保留 mcr.microsoft.com/mssql/server:2019-latest 的容器时权限被拒绝 - Permission denied when persisting a container of mcr.microsoft.com/mssql/server:2019-latest using Docker volumes Windows卷问题上的Visual Studio 2017 Docker项目 - Visual Studio 2017 Docker project on Windows volumes issue 如何在Asp核心Web应用程序(MVC)上创建和使用docker卷 - How to create and use docker volumes on Asp core Web app (MVC) Microsoft Office Excel 无法访问 IIS 上的文件 - Microsoft Office Excel cannot access the file on IIS IIS + microsoft.Office.Interop.Word - IIS + microsoft.Office.Interop.Word IIS:使用AppPool身份访问Microsoft CRM 2013 - IIS: Access Microsoft CRM 2013 with AppPool Identity IIS 中的 Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery 错误 - Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery Error in IIS 如何在IIS管理器中内部托管Microsoft Bot - How to host Microsoft Bot on premise in IIS manager Blazor 带有微软身份的服务器 IIS 带有虚拟应用 - Blazor Server with Microsoft Identity in IIS with virtual application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM