【发布时间】:2021-06-18 01:53:50
【问题描述】:
我尝试更熟悉 docker-compose 和 nginx,但遇到了这个问题。 我想用 nginx 启动一个 docker 容器,并在 nginx 配置中更改根卷。
所以起初这是我的 docker-compose.yml:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./code:/code
- ./site.conf:/etc/nginx/conf.d/site.conf
这是我的 site.conf:
server {
index index.html;
server_name php-docker.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /code;
}
在我的 /code 目录中有一个简单的 Hello World HTML 文件,名为 "index.html"。
如果我运行 docker-compose up 并使用 URL php-docker.local(我也将它添加到我的 /etc/hosts),我只会得到“欢迎使用 nginx”站点,而不是我的 HTML 文件。
我还直接在docker容器中检查了nginx.conf,如果这没有加载我的site.conf,但它将包含在include /etc/nginx/conf.d/*.conf;
有人知道我做错了什么吗?我也搜索了很多,但只找到这样的例子。
非常感谢您!
【问题讨论】:
标签: docker nginx docker-compose