dockerdocker-composeinfluxdbchronograf

Docker inter-container communication


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?


Solution

  • 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.