[英]Docker Grafana with two InfluxDBs: Connection refused
i created a new docker-stack where i would need several influxdb instances, which i can't connect to my grafana container atm.我创建了一个新的 docker-stack,我需要几个 influxdb 实例,我无法连接到我的 grafana 容器 atm。 Here is a port of my docker-compose.yml
这是我的 docker-compose.yml 的一个端口
services:
grafana:
image: grafana/grafana
container_name: grafana
restart: always
ports:
- 3000:3000
networks:
- monitoring
volumes:
- grafana-volume:/var/lib/grafana
influxdb:
image: influxdb
container_name: influxdb
restart: always
ports:
- 8086:8086
networks:
- monitoring
volumes:
- influxdb-volume:/var/lib/influxdb
influxdb-2:
image: influxdb
container_name: influxdb-2
restart: always
ports:
- 12380:12380
networks:
- monitoring
volumes:
- influxdb-volume-2:/var/lib/influxdb
When i try to create a new influxdb datasource in grafana with influxdb-2 i get a Network Error: Bad Gateway(502), the logfile is showing:当我尝试使用 influxdb-2 在 grafana 中创建新的 influxdb 数据源时,出现网络错误:错误网关(502),日志文件显示:
2782ca98a4d7_grafana | 2019/10/05 13:18:50 http: proxy error: dial tcp 172.20.0.4:12380: connect: connection refused
Any ideas?有任何想法吗?
Thanks谢谢
@hmm provides the answer. @hmm 提供了答案。
When you create services within Docker Compose, you:在 Docker Compose 中创建服务时,您:
influxdb-2
by that name. influxdb-2
。influxdb-2
must still be referenced on port 8086
because that's the port the container exposes;8086
上引用influxdb-2
,因为这是容器公开的端口; you can't change it unless you change the image.--ports: [[HOST-PORT]]:[[CONTAINER-PORT]]
--ports: [[HOST-PORT]]:[[CONTAINER-PORT]]
Long and the short of it is that the InfluxDB service in influxdb-2
should be referenced as influxdb-2:8086
.总而言之,应该将
influxdb-2
中的 InfluxDB 服务引用为influxdb-2:8086
。 If you want to expose this service to the host (,), you could do ports: - 12380:8086
.如果你想将此服务公开给主机(,),你可以做
ports: - 12380:8086
。 You may change the value of 12380
to something available on your host but you cannot change the value of the container port ( 8086
).您可以将
12380
的值更改为主机上可用的值,但不能更改容器端口 ( 8086
) 的值。
The main reason that you would include the --ports:
flag on influxdb-2
is for debugging from the host.在
influxdb-2
上包含--ports:
标志的主要原因是为了从主机进行调试。 But the grafana
service does not require this.但是
grafana
服务不需要这个。 It will access the influxdb-2
service through the network provisioned by Docker Compose on port 8086
.它将通过 Docker Compose 在端口
8086
上提供的网络访问influxdb-2
服务。
You do want to expose the grafana
service on the host because, otherwise, it would be inaccessible to you (from the host).您确实希望在主机上公开
grafana
服务,否则,您(从主机)将无法访问它。 It's akin to public|private.它类似于公共|私人。
grafana
is host public but the influxdb*
services may be host private because they are generally only needed by the grafana
service. grafana
是主机公共的,但influxdb*
服务可能是主机私有的,因为它们通常只被grafana
服务需要。
HTH! !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.