Score:0

How I can offer a local-only domain resolution once I run docker-compose up?

fr flag

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?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.