Random container IP

I’m running on a Raspberry 4, Ubuntu 19.10 and Home Assistant is in Docker.

Each time I reboot some of the containers, especially influxDB (but this happend with others) change their IP which breaks everything till I change the config files.

Is there any way to get statis IPs for the containers ? Who is responsible for giving the 172.x.x.x IPs ? And how to configure it ?

I don’t think I’m supposed to change config files according to new IP after each reboot, no ?

Who is responsible for giving the 172.x.x.x IPs

That would be from docker itself. Typically you want to use the container name rather than the IP address to connect. For example my docker-compose for nextcloud, when I connect to the postgres database I use db:5432 rather than 172.x.x.x:5432

version: '2'

services:
  db:
    image: postgres:alpine
    restart: always
    volumes:
      - db:/var/lib/postgresql/data
    env_file:
      - .env
    networks:
      - nextcloud_net

  app:
    image: nextcloud:apache
    restart: always
#[Trimed...]
    networks:
      - nextcloud_net

volumes:
  db:
  nextcloud:

networks:
  nextcloud_net:

Alternatively you can forcibly define an IP address by using an ipam driver for the network. However this should be avoided if you can.

  db:
    image: postgres:alpine
    restart: always
    volumes:
      - db:/var/lib/postgresql/data
    env_file:
      - .env
    networks:
      nextcloud_net:
        ipv4_address: 172.28.0.2

#[Trimed...]

networks:
  nextcloud_net:
    ipam:
      driver: default
      config:
      - subnet: 172.28.0.0/24

So I’ll have to learn how to use a Docker compose file, I don’t even know where is this file for the existing containers of the default install.
Apart from this problem Docker seems to be a really good solution, in particular for updates. I’m wondering if there’s no a more simple solution, something in the configuration.yaml…