nginx-prometheus-exporter 容器无法连接到 nginx

no7*_*746 5 nginx docker-compose docker-network

我有一个 docker-compose,nginx 和 nginx-prometheus-exporter 都是容器。我把相关部分放在这里:

  nginx:
    container_name: nginx
    image: nginx:1.19.3
    restart: always
    ports:
      - 80:80
      - 443:443
      - "127.0.0.1:8080:8080"

  nginx-exporter:
    image: nginx/nginx-prometheus-exporter:0.8.0
    command:
      -nginx.scrape-uri
      -http://127.0.0.1:8080/stub_status

Run Code Online (Sandbox Code Playgroud)

我尝试过 http://nginx:8080/stub_statusnginx:8080/stub_status但 没有一个有效,但我成功127.0.0.1:8080/stub_status了。-nginx.scrape-uriCould not create Nginx Client: failed to get http://127.0.0.1:8080/stub_status: Get "http://127.0.0.1:8080/stub_status": dial tcp 127.0.0.1:8080: connect: connection refused

另外,使用curl 在我的虚拟机中可以使用localhost:8080/stub_status。

no7*_*746 6

问题是失踪了-

 nginx:
    container_name: nginx
    image: nginx:1.19.3
    restart: always
    ports:
      - 80:80
      - 443:443
      - "127.0.0.1:8080:8080"

  nginx-exporter:
    image: nginx/nginx-prometheus-exporter:0.8.0
    command:
      - -nginx.scrape-uri
      - http://127.0.0.1:8080/stub_status
Run Code Online (Sandbox Code Playgroud)