Mac OS在这里,运行Docker版本17.12.0-ce-mac49.我有以下超级简单的Dockerfile:
<code>FROM nginx COPY index.html /usr/share/nginx/html </code>
我创建了我的Docker镜像:
<code>docker build -t mydocbox . </code>
到目前为止这么好,没有错误.然后我从该图像创建一个容器:
<code>docker run -it -p 8080:8080 -d --name mydocbox mydocbox </code>
而且我看到它正在运行(我已通过发布docker ps以及通过docker exec -it< containerId> bash并确认/usr/share/nginx/html/index.html存在而通过SSH进入框中确认了它的运行情况)!
当我打开浏览器并转到http:// localhost:8080时,我得到一个空的/空白/没有看到这里的屏幕,而不是我期望的index.html页面.
我没有在任何地方看到任何错误,没有任何迹象表明配置错误或防火墙导致问题.关于问题可能是什么或我如何排除故障的任何想法?
解决方法:
看看你是否可以关注this example:
<code>FROM nginx:alpine COPY default.conf /etc/nginx/conf.d/default.conf COPY index.html /usr/share/nginx/html/index.html </code>
它使用default.conf file指定使用的index.html
<code>location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
</code>
将default.conf中的侦听端口从80更改为8080,并将其EXPROP.
或者简单地使用-p 8080:80(hostPort:containerPort)运行docker.
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!