Docker networking issue

Last weekend I took the plunge and reinstalled my home server, upgrading it to Ubuntu 18.04 after having had a number of problems with the previous installation. Instead of running a couple of KVM machines I decided to move everything to Docker. So far I installed Docker CE, Docker Compose and a number of stand-alone containers without problems but when it comes to HASS, InfluxDB and Grafana I’m at a loss.

My original idea was to use a separate compose file for each container but I can’t make out the network settings for the three containers. I’ve tried creating a bridged network, using the _default network, linking and network_mode=host in various combinations. Maybe it’s easier to use a single compose file anyway but how do I set up the networking there?

Can someone help me with a working example of docker-compose.yml with (at least) the three services mentioned above?

Obviously I want HASS and Grafana to be accessible in my browser.

I’ve only just recently moved to Docker also, I used this: My Home Assistant setup: RPi 3B, Docker Compose, Node-RED, SSL, client certs, etc…

Here’s my docker-compose.yaml:

version: '2.1'
services:
  grafana:
    container_name: grafana
    image: fg2it/grafana-armhf:v5.0.4
    ports:
      - 3000:3000
    volumes:
      - /docker/grafana:/etc/grafana:rw
      - /docker/grafana:/var/lib/grafana:rw
    restart: on-failure
    depends_on:
      influxdb:
        condition: service_healthy

  influxdb:
    container_name: influxdb
    image: influxdb
    ports:
      - 8086:8086
    volumes:
      - /docker/influxdb/influxdb.conf:/etc/influxdb/influxdb.conf:ro
      - /docker/influxdb:/var/lib/influxdb
    restart: on-failure
    healthcheck:
      test: ["CMD", "curl", "-sI", "http://127.0.0.1:8086/ping"]
      interval: 30s
      timeout: 1s
      retries: 24
      
  node-red:
    container_name: node-red
    image: nodered/node-red-docker:rpi-v8
    ports:
      - 1880:1880
    volumes:
      - /docker/node-red:/data
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    restart: on-failure
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:1880"]
      interval: 30s
      timeout: 10s
      retries: 5

  portainer:
    container_name: portainer
    image: portainer/portainer
    ports:
      - 9000:9000
    volumes:
      - /docker/portainer:/data:rw
      - /var/run/docker.sock:/var/run/docker.sock
    restart: on-failure

  dockermon:
    container_name: dockermon
    image: tribunex/ha-dockermon-pi
    ports:
      - 8126:8126
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /docker/dockermon:/config
    restart: on-failure

  home-assistant:
    container_name: home-assistant
    image: homeassistant/raspberrypi3-homeassistant:0.70.0
    network_mode: "host"
    restart: on-failure
    volumes:
      - /docker/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
      - /etc/letsencrypt:/etc/letsencrypt:ro
    devices:
      - /dev/ttyACM0:/dev/ttyACM0

And my relevant conf.yaml:

  host: 127.0.0.1
  port: 8086
  database: homeassistant
  default_measurement: state
# exclude stuff that is pointless to log
  exclude: 
    domains:
      - group

Cheers, I’ll have a look later tonight!