How to add extra hosts to docker containers

If you need to add extra hosts to any of the docker services, you can do that by adding them in the docker-compose.override.yml file, which is located in /home/fleio/compose.

The following syntax should be used:

version: "3.7"
services:
  backend:
    extra_hosts:
      - "example1:10.10.10.2"
      - "example2:10.10.10.3"
  celery:
    extra_hosts:
      - "example1:10.10.10.2"
      - "example2:10.10.10.3"
  celerybeat:
    extra_hosts:
      - "example1:10.10.10.2"
      - "example5:10.10.10.3"
  operations:
    extra_hosts:
      - "example1:10.10.10.2"
      - "example2:10.10.10.3"
  updated:
    extra_hosts:
      - "example1:10.10.10.2"
      - "example6:10.10.10.6"
  incomingmail:
    extra_hosts:
      - "example1:10.10.10.2"

Finally, you need to run fleio recreate in order to apply the changes. Note that all Fleio containers will be re-created, so any manual change inside docker containers will be lost.

Besides the containers required to run Fleio, there is also the utils container, which is used for commands like fleio bash or fleio shell. You might need to extra hosts for debugging commands like ping or telnet. To add hosts to the utils container edit file /home/fleio/compose/docker-compose.utils.override.yml

version: "3.7"

services:
  utils:
    extra_hosts:
      - "example1:10.10.10.2"
      - "example2:10.10.10.3"