I have the following docker-compose:
version: "3.1"
services:
nginx:
image: nginx
networks:
frontend:
ipv4_address: 172.20.0.5
outgoing:
ipv4_address: 172.20.1.5
volumes:
- "./configuration/nginx.conf:/etc/nginx/nginx.conf:ro"
- "./configuration/service-local.key:/etc/nginx/service-local.key:ro"
- "./configuration/service-local.crt:/etc/nginx/service-local.crt:ro"
- "website:/var/www/html/website"
- "api:/var/www/html/api"
extra_hosts:
- "api:172.20.0.3"
- "website:172.20.0.4"
api:
image: php
volumes:
- "api:/var/www/html/api"
networks:
- frontend
extra_hosts:
- "api.local:172.20.0.5"
dns:
- 8.8.8.8
- 9.9.9.9
networks:
frontend:
ipv4_address: 172.20.0.3
website:
image: php
volumes:
- "api:/var/www/html/api"
networks:
- frontend
extra_hosts:
- "api.local:172.20.0.5"
dns:
- 8.8.8.8
- 9.9.9.9
networks:
frontend:
ipv4_address: 172.20.0.4
volumes:
website:
driver: local
driver_opts:
type: "none"
o: "bind"
device: $WEBSITE_DIR
api:
driver: local
driver_opts:
type: "none"
o: "bind"
device: $API_DIR
networks:
backend:
ipam:
config:
- subnet: 172.20.0.0/24
frontend:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.20.1.0/24
All the incoming traffic will pass through frontend
traffic.
The setup above is used for app development in my local machine.
For development we use the following hostnames placed diurectly in /etc/hosts
or each hosts
file of every developer:
api.local
for the api executed in api container.
website.local
for the actual website executed in website
container.
Also I have an android app where I use it for mobile app testing that use the domains above. How I can provide some sort of DNS for my apps in a specific network served from each developer's machine?