If you’re running the Astronomer CLI and need to add an entry to the hosts file, follow the steps below.
Customize your Docker Compose Override File
- Create a
docker-compose.override.yml
file in your Airflow project directory. - Use the following template to add your hosts:
version: "2" services: webserver: extra_hosts: - "test-server:127.1.2.3" - "different-server:125.2.3.4" scheduler: extra_hosts: - "test-server:127.1.2.3" - "different-server:125.2.3.4"
Make sure to specify version: "2"
and mimic the format of the source code file linked above.
Confirm that Hosts were Added
If you bash into your Scheduler or Webserver container locally and view the contents of your /etc/hosts
file, you should then see the hosts you added correctly render.
- Run
$ docker ps
- Copy the
CONTAINER ID
of either your Scheduler or Webserver Container. - Run
$ docker exec -it <CONTAINER-ID> bash
- Run
$ cat /etc/hosts
- See:
127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 125.2.3.4 different-server 127.1.2.3 test-server 192.168.32.3 d5c8441ece31