fps_boost
fps_boost

Reputation: 51

InfluxDB in Docker Bad gateway

I started setting up my Smart Home System in Docker with Openhab, mosquitto, Grafa etc. The Docker topic is still relatively new to me and I have not managed to connect InfluxDB with Grafana. Whenever I try, Influxdb: Bad Gateway appears. I did a lot of research on the Internet, but I couldn't find a solution that could help me. Maybe someone knows the problem and can help me. Here is my docker-compose file:

influxdb:
image: influxdb:latest
container_name: influxdb
restart: always
ports:
  - 8086:8086
environment:
  - INFLUXDB_DB=telegraf
  - INFLUXDB_USER=telegraf
  - INFLUXDB_ADMIN_ENABLED=true
  - INFLUXDB_ADMIN_USER=admin
  - INFLUXDB_ADMIN_PASSWORD=Welcome1 
volumes:
  - influxdb:/var/lib/influxdb

grafana:
   container_name: "grafana"
   image: "grafana/grafana:latest"
   restart: always
   ports:
    - 3000:3000
   volumes: 
    - ./grafana:/var/lib/grafana

Upvotes: 5

Views: 7670

Answers (2)

mrq
mrq

Reputation: 567

Grafana+InfluxDB datasource setup dialogue propose http://localhost:8086 as default for URL field. This is a suggestion to leave it like this, being grafana and influxdb indeed on the same host

enter image description here

And this results in the BAD Gateway error.

Problem is they are also two services inside docker and they should refer each other through the name of their docker compose sections so, in your case, like this

enter image description here

Regarding your volumes sections, the one in influxdb declaration probably should have been:

volumes:
    - ./influxdb:/var/lib/influxdb

to map the container folder /var/lib/influxdb to the host folder ./influxdb, next to the ./grafana one but this is not related to the BAD Gateway issue.

Upvotes: 4

Shashank Sinha
Shashank Sinha

Reputation: 557

volumes section was missing. Here is the working one.

version: '3'
services:
  influxdb:
    image: influxdb:latest
    container_name: influxdb
    restart: always
    ports:
    - 8086:8086
    environment:
    - INFLUXDB_DB=telegraf
    - INFLUXDB_USER=telegraf
    - INFLUXDB_ADMIN_ENABLED=true
    - INFLUXDB_ADMIN_USER=admin
    - INFLUXDB_ADMIN_PASSWORD=Welcome1
    volumes:
    - influxdb:/var/lib/influxdb

  grafana:
    container_name: "grafana"
    image: "grafana/grafana:latest"
    restart: always
    ports:
    - 3000:3000
    volumes:
    - grafana:/var/lib/grafana
volumes:
  influxdb:
  grafana:

Upvotes: 0

Related Questions