【问题标题】:Docker with nginx shows only nginx start html带有 nginx 的 Docker 仅显示 nginx start html
【发布时间】: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


    【解决方案1】:

    好吧,我发现我的错了: 我需要在浏览器中运行php-docker.local:8080

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-29
      • 2021-12-30
      • 2022-11-13
      • 2015-03-01
      • 1970-01-01
      • 2019-03-22
      • 2021-06-03
      相关资源
      最近更新 更多