本文介绍了无法从浏览器访问IIS容器-Docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows版本:Windows Server 2016



Docker for Windows版本:18.09.0





我尝试遵循



以上所有步骤都可以,但我无法访问该网站,



我尝试了以下每种组合:
ipconfig中的IP地址:8000或80;来自inspect的ip地址:8000 /80。
请注意,我还设置了防火墙以允许端口8000





但这一切都失败了。



然后,我去了互联网,发现了我可以实际地称呼bash。因此,我执行了exec,但是,发生了一些奇怪的事情:





我不确定这是否表示该容器没有工作?
但是检查和容器ls显示它应该可以工作。



fyi
网络:



检查容器:




我真的无法从互联网上找到任何解决方案



任何建议都会有所帮助,谢谢

解决方案

更新:我懂了ork具有以下配置,并具有远程IIS访问权限。确保防火墙没有将docker阻止到您的本地IP。另外,在我们的案例中,该应用程序是网站的一部分,因此我们需要使用Webadministration将该应用程序部署为应用程序,以使其正常运行。日志和其他所有内容现在都可以正常运行,并且我们正在运行一个示例。



我一直在使用Docker容器,并且在部署时遇到了类似的问题。我使用的是服务器核心映像,因为它上面具有完整的功能,但是我在执行测试时定义了这样的dockerfile来构建映像,因为应用程序似乎无法启动。该应用还不是核心,但将很快迁移到该应用,以缩小工作图像。此示例要注意的另一件事是,即使在我的命令中定义了应用程序池,也不会创建该应用程序池。使用此工具,您可以与iis远程管理工具进行远程连接,并检查在docker中到目前为止服务器的安装方式。

  ##从mcr.microsoft.com/windows/servercore/iis中拉出基础图像以使用

#在出现错误的情况下启用详细输出
SHELL [ powershell,-命令, $ ErrorActionPreference ='Stop';]
#安装IIS的所有必需功能
RUN Install-WindowsFeature -name Web-Server -IncludeManagementTools; \
Install-WindowsFeature-名称Web-Basic-Auth; \
Install-WindowsFeature-名称Web-Windows-Auth; \
Install-WindowsFeature -name Web-Net-Ext45; \
Install-WindowsFeature -名称Web-ISAPI-Ext; \
Install-WindowsFeature-名称Web-ISAPI-Filter; \
Install-WindowsFeature -name Web-WHC; \
Install-WindowsFeature NET -Framework-45-ASPNET; \
Install-WindowsFeature-名称Web-Mgmt-Service; \
Install-WindowsFeature-名称Web-Mgmt-Service; \
Install-WindowsFeature-名称Web-Mgmt-Tools; \ \
Install-WindowsFeature -name Web-Mgmt-Compat; \
Install-WindowsFeature -name Web-Scripting-Tools; \
Dism / online / enable-feature / featurename:IIS -ManagementService / all; \
##仍在同一运行命令内,在docker
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server上启用IIS的远程管理-名称EnableRemoteManagement-值1-强制; \
获取服务-名称WMSVC | Start-Service; \
Set-Service –名称WMSVC –StartupType'Automatic'; \
##在同一运行命令中添加IIS远程管理用户和密码
net user myuser superP @ ss123 / ADD; \
本地组净管理员myuser / add

COPY。 myapp
RUN New-WebAppPool myapp
#configStore是网站的应用程序,因此应将其添加到服务
RUN Import-Module WebAdministration中; Get-Module; \
新建项'IIS:Sites\默认网站\myapp'-physicalPath'c:\myapp'-ApplicationPool'myapp'-类型'Application'

EXPOSE 51329 80

另一个我没有答案的问题是我们是否可以实际分配内存在创建时大小与Docker映像的大小有关,而不仅仅是所有者的标准。


Windows Version: Windows Server 2016

Docker for Windows Version: 18.09.0

I try to follow the steps in https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-images

I have a Docker file on c:\Build:

FROM microsoft/iis
RUN echo "Hello World - Dockerfile" > c:\inetpub\wwwroot\index.html

Please note that I have tried using FROM microsoft/iis:10.0.14393.206 as well

So, I ran using powershell with admin privilege:

docker build -t imagename c:\Build

Then I ran:

docker run -d -p 8000:80 --name container imagename ping -t localhost

All of the above steps are fine, but I cannot access the website,

I tried every combination like:the ip address from ipconfig:8000 or 80; the ip address from inspect :8000 / 80.Please note that I had also set up Firewall to allow port 8000 as well

But it all failed.

Then, I went to the Internet and found that I can actucally call the bash. therefore, I ran exec, however, there was something strange happened:

I am not sure whether it means the container is not worknig?But the inspect and container ls show it should be working.

fyinetwork:

inspect container:

I really cannot find any solution from the Internet

Any advice would be helpful, thanks

解决方案

UPDATE: I got it to work with the following configuration below, and with remote IIS access. Make sure that firewall is not blocking docker to your local ip's. Also, the app in our case is part of a website, so we need to use Webadministration to deploy it as an application to make it work. Logs and everything else is working now and we have a running sample.

I been playing as well with the docker container and I been having similar issues deploying. I am using a server core image instead as it has full fledge powershell on it, but I have my dockerfile defined like this to build the image at the moment doing tests because the application seems to not start. the app is not on core yet but will migrate to it soon to make the working image smaller. Another thing to note from this sample, the application pool is not getting created even tho its being defined on my commands. With this you can connect remotely with the iis remote management tool and check how is the server setup up to this point inside the docker.:

##Pull the base image to use
FROM mcr.microsoft.com/windows/servercore/iis
#Enable verbose output in case of errors
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
#install all needed features of IIS
RUN Install-WindowsFeature -name Web-Server -IncludeManagementTools ;\
    Install-WindowsFeature -name Web-Basic-Auth ;\
    Install-WindowsFeature -name Web-Windows-Auth ;\
    Install-WindowsFeature -name Web-Net-Ext45 ;\
    Install-WindowsFeature -name Web-ISAPI-Ext ;\
    Install-WindowsFeature -name Web-ISAPI-Filter ;\
    Install-WindowsFeature -name Web-WHC ;\
    Install-WindowsFeature NET-Framework-45-ASPNET ; \
    Install-WindowsFeature Web-Asp-Net45 ;\
    Install-WindowsFeature -Name Web-Mgmt-Service ;\
    Install-WindowsFeature -name Web-Mgmt-Tools ;\
    Install-WindowsFeature -name Web-Mgmt-Compat ;\
    Install-WindowsFeature -name Web-Scripting-Tools ;\
    Dism /online /enable-feature /featurename:IIS-ManagementService /all ;\
    ##Still inside the same run command, enable remote management for IIS on docker
    New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force ;\
    Get-Service -Name WMSVC | Start-Service ;\
    Set-Service –Name WMSVC –StartupType 'Automatic' ;\
    ##In the same run Command add the user and password for IIS remote management
        net user myuser superP@ss123 /ADD ;\
        net localgroup administrators myuser /add

    COPY . myapp
    RUN New-WebAppPool myapp
#The configStore is an application of a website, so add it as such to the service
RUN Import-Module WebAdministration; Get-Module ;\
    New-Item 'IIS:Sites\Default Web Site\myapp' -physicalPath 'c:\myapp' -ApplicationPool 'myapp' -type 'Application'

EXPOSE 51329 80

The other question I have no answer is if we can actually assign a memory size to the docker images on creation and not just the standard by the owner.

这篇关于无法从浏览器访问IIS容器-Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 07:17