Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose, use include with networks #785

Open
rami-foo opened this issue Feb 11, 2025 · 0 comments
Open

Docker compose, use include with networks #785

rami-foo opened this issue Feb 11, 2025 · 0 comments
Assignees
Labels
community_new New idea raised by a community contributor

Comments

@rami-foo
Copy link

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-foo rami-foo added the community_new New idea raised by a community contributor label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_new New idea raised by a community contributor
Projects
None yet
Development

No branches or pull requests

2 participants