【发布时间】:2021-03-02 06:40:47
【问题描述】:
我正在尝试使用 Nginx 托管一个简单的 index.html 文件来做最简单的容器。但我似乎无法让它工作。我一定在某个地方遗漏了一个概念,我希望能得到一些帮助。
这是我正在做的事情:
我有一个文件夹,里面有 2 个文件:
-
Dockerfile
FROM nginx:1.18.0 WORKDIR /usr/share/nginx/html COPY index.html ./ -
index.html
<!DOCTYPE html> <html> <head> <title>Testing</title> </head> <body> <p>Hello Test App</p> </body> </html>
首先我构建容器。从包含文件的文件夹中,我运行以下命令:
docker image build --tag nginx-test:1.0.0 --file ./Dockerfile .
然后我运行容器:
docker run -d -p 3737:3737 nginx-test:1.0.0
然后我浏览到 http://localhost:3737(我也尝试过 http://localhost:3737/index.html)并且 chrome 显示 ERR_EMPTY_RESPONSE 错误:
如何让我的 index.html 文件托管在我的容器中?
【问题讨论】:
标签: docker nginx containers