roadmap icon indicating copy to clipboard operation
roadmap copied to clipboard

Docker compose, use include with networks

Open Rami-Kassouf-FOO opened this issue 1 year ago • 0 comments

Tell us about your request I want to split the docker composes for clarity but have 1 main compose to group them up when building tests for consistency. So i am using include in conjunction with networks

Which service(s) is this request for? docker compose

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? My service in the front/ folder can t seem to acces the back folder's gateway service

I am trying to split my docker compose into 2 compose files: for example:

#front/docker-compose.yaml

services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: web
    ports:
      - "80:80"
    networks:
      - project_gateway

networks:
  project_gateway:
    external: true

#back/docker-compose.yaml

services:
  gateway_service:
    build:
      context: ./gatewayService
      dockerfile: Dockerfile
    container_name: gateway_service
    ports:
      - "8000:8000"
    networks:
      - project_backend
      - project_gateway

  service_1:
    build:
      context: ./service_1
      dockerfile: Dockerfile
    container_name: service_1
    ports:
      - "8001:8001"
    networks:
      - project_backend
networks:
  project_backend:
    external: true
  project_gateway:
    external: true

and outside: #./docker-compose.yaml

networks:
  backend:
    driver: bridge
  gateway:
    driver: bridge


include:
  - back/docker-compose.yaml
  - front/docker-compose.yaml

Are you currently working around the issue? docker-compose -f docker-compose.yaml -f back/docker-compose.yaml -f front/docker-compose.yaml up Should be a working alternative

Additional context stackoverflow#79430123

Rami-Kassouf-FOO avatar Feb 11 '25 14:02 Rami-Kassouf-FOO