Docker Compose v3 (example 1)

version: '3'

services:

  postgres-1-db:
    container_name: "postgres-1-db"
    build: ./postgres
    environment:
      POSTGRES_USER: '${DB_USER}'
      POSTGRES_PASSWORD: '${DB_PASSWORD}'
      POSTGRES_DB: '${DB_NAME}'
    networks:
      - btbw_corp

  postgres-2-db:
    container_name: "postgres-2-db"
    build: ./postgres
    environment:
      POSTGRES_USER: '${DB_USER}'
      POSTGRES_PASSWORD: '${DB_PASSWORD}'
      POSTGRES_DB: '${DB_NAME}'
    networks:
      - btbw_corp

  web-post-service:
    container_name: "web-post-service"
    build: ./web_post-service
    ports:
      - "8081:8080"
    networks:
      - btbw_corp
    environment:
      DB_HOST: 'postgres-1-db'
      DB_USER: '${DB_USER}'
      DB_PASSWORD: '${DB_PASSWORD}'
      DB_NAME: '${DB_NAME}'

  web_category-service:
    container_name: "web_category-service"
    build: ./web_category-service
    ports:
      - "8082:8080"
    networks:
      - btbw_corp
    environment:
      DB_HOST: 'postgres-2-db'
      DB_USER: '${DB_USER}'
      DB_PASSWORD: '${DB_PASSWORD}'
      DB_NAME: '${DB_NAME}'

networks:
  btbw_corp:

run.sh

#!/usr/bin/env bash
docker build -t web_base ./web_base
docker-compose up -d