skip to Main Content

I am experimenting with docker and trying to create a demo of everything working without having to commit anything yet. I have multiple git repos that have services within them. We clone all these projects into a central folder.

I want to create a new docker project that references the individual dockerfiles – this way I can build up my demo without having to re-structure everything – e.g.

Projects/
├── orchestratorService/
│   └── Dockerfile
├── microserviceB/
│   └── Dockerfile
└── microserviceC/
|   └── Dockerfile
└── docker/
    └── dockercompose.yaml

My problem is that the dockercompose file will only recognise things within the same folder. This means it can’t "see" the other folders in the Projects/ directory.

I don’t want to move the dockercompose file into Projects/ as that folder is not part of a repo.

Is there any advice on how to do this?

2

Answers


  1. Chosen as BEST ANSWER

    For some reason I thought the projects had to be in the same folder as the docker-compose file. I now realise I can do something like the following, where the docker-compose file is referencing files that are in sibling folders.

    services;
      microserviceA:
        build: ../microserviceA/.
      microserviceB:
        build: ../microserviceB/.
    

  2. let me try to answer your question as I understand
    I think your question is straight forward it is possible to do as u said so structure your docker compose file as the following

    version: "3.9"
    
    services:
      MicroServiceA:
        build:
          context: MicroServiceA
      MicroServiceB:
        build:
          context: MicroServiceB
    .
    .
    .
    .
    

    when you give context the folder name it access docker file directly

    write me more explanation if I miss your question

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search