0

I'm facing a relatively simple problem here but I'm starting to wonder why it doesn't work.

I want to start two Docker Containers with Docker Compose: InfluxDB and Chronograph.

Unfortunately, the chronograph does not reach InfluxDB under the given hostname: "Unable to connect to InfluxDB Influx 1: Error contacting source"

What could be the reason for this?

Here is my docker-compose.yml:

version: "3.8"

services:
  influxdb:
    image: influxdb
    restart: unless-stopped
    ports:
      - 8086:8086
    volumes:
      - influxdb-volume:/var/lib/influxdb
    networks:
      - test

  chronograf:
    image: chronograf
    restart: unless-stopped
    ports:
      - 8888:8888
    volumes:
      - chronograf-volume:/var/lib/chronograf
    depends_on:
      - influxdb
    networks:
      - test

volumes:
  influxdb-volume:
  chronograf-volume:

networks:
  test:
    driver: bridge

I have also tried to start a shell inside the two containers and then ping the containers to each other or use wget to get the HTTP-API of the other container. Even this communication between the containers does not work. On both attempts with wget and ping I get timeouts.

It must be said that I use a Banana Pi BPI-M1 here. Is it possible that it is somehow due to the Linux that container to container communication does not work?

n0nvme
  • 1,248
  • 8
  • 18
A. Fendt
  • 77
  • 9

2 Answers2

2

If not configured, chronograf will try to access influxdb on localhost:8086. To be able to reach the correct influxdb instance, you need to specify the url accordingly using either the --influxdb-url command line flag or (personal preference) an environment variable INFLUXDB_URL. Those should be set to the value of http://influxdb:8086 which is the docker DNS name derived from the service name of your compose file (the keys one level below services).

This should do the trick (snippet):

  chronograf:
    image: chronograf
    restart: unless-stopped
    ports:
      - 8888:8888
    volumes:
      - chronograf-volume:/var/lib/chronograf
    environment:
      - INFLUXDB_URL=http://influxdb:8086
    depends_on:
      - influxdb
    networks:
      - test

Please check the chronograf readme (section Using the container with InfluxDB) for details on configuring the image and check the docker compose networking docs on some more info about networks and dns naming.

Andreas Jägle
  • 11,632
  • 3
  • 31
  • 31
  • Many thanks for the hint. I have also tried this variant. Although Chronograph doesn't ask me for the configuration at start, it still doesn't work. In the log I get the following error messages: level=info msg="Failed to retrieve database version" error="request to backend timed out – A. Fendt Oct 26 '20 at 19:48
  • 1
    I'm not sure about the precedence of config values if there might already be something stored in the chronograf volume. If you don't have relevant data in the influx yet, I'd try to start from a clean state by `docker-compose down -v` or by manually removing the chronograf named volume like here. https://stackoverflow.com/a/58423521/4854965 does that help? – Andreas Jägle Oct 27 '20 at 08:34
  • 1
    Can you check if the influxdb is definitely running and responding to requests by sending a request to the mapped port on your host machine or by using the influx tool to do so? – Andreas Jägle Oct 27 '20 at 08:39
  • Thanks for your help. I found out that another component on my system empties the iptables tables nat and filter on startup. Because of this the inter-container communication did not work anymore. – A. Fendt Oct 27 '20 at 13:08
  • thanks, when I changed localhost to influxdb it worked for me. – tito.300 Sep 29 '21 at 15:33
-1

The Docker service creates some iptables entries in the tables filter and nat. My OpenVPN Gateway script executed the following commands at startup:

iptables --flush -t filter
iptables --flush -t nat

This will delete the entries from Docker and communication between the containers and the Internet will no longer be possible.

I have rewritten the script and now everything works again.

A. Fendt
  • 77
  • 9