简体   繁体   English

在 Docker 中运行 IIS 时无法访问站点

[英]Site can't be reached when running IIS in Docker

I followed the instructions on the official Dockerhub repo for IIS ( https://hub.docker.com/_/microsoft-windows-servercore-iis ), but running into "Site can't be reached" when trying to access via the IP of the container. I followed the instructions on the official Dockerhub repo for IIS ( https://hub.docker.com/_/microsoft-windows-servercore-iis ), but running into "Site can't be reached" when trying to access via the容器的 IP。

I get 403 forbidden when I try htp://localhost:8000.当我尝试 htp://localhost:8000 时,我得到403 forbidden I copied a test.html page into C:/inetpub/wwwroot and verified by logging into the container as well.我将test.html页面复制到C:/inetpub/wwwroot并通过登录容器进行验证。

The results of appcmd list site is as follows: appcmd list site的结果如下:

SITE "Default Web Site" (id:1,bindings:http/*:80:,state:Started)站点“默认 Web 站点”(id:1,bindings:http/*:80:,state:Started)

403 typically indicates that the web address we are trying to access is not the root directory of the website. 403通常表示我们试图访问的web地址不是网站的根目录。
I doubt if there exist any files, which have been copied to the remote docker container.我怀疑是否存在任何已复制到远程 docker 容器的文件。 Please make sure that the directory where the dockerfile is located contains the content folder and contains all site files.请确保dockerfile所在目录包含内容文件夹并包含所有站点文件。

WORKDIR /inetpub/wwwroot

COPY content/ .

Feel free to let me know if the problem persists.如果问题仍然存在,请随时告诉我。

You are right in your analysis.你的分析是对的。 What i didn't realize is IIS perhaps serves index.html as default and my file was called helloworld.html which obviously wasn't going to be to served when i access localhost:8000;我没有意识到 IIS 可能服务 index.html 作为默认值,我的文件名为 helloworld.html 当我访问 localhost:8000 时显然不会服务it works when i try localhost:8000/helloworld.html.当我尝试 localhost:8000/helloworld.html 时它可以工作。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM