9

From the count of questions tagged with docker i assume StackOverflow is the right place to ask (instead of e.g. DevOps), if not, please point me to the right place or move this question accordingly.

My scenario is the following:

  • multiple applications consisting of frontend (web GUI) and backend (REST services) are being developed following SOA/microservice approaches, each application has its own git repository
  • some applications require a shared additional resource like frontend needs a HTTP server and multiple backend applications need a database server (with persistent storage)
  • focus is primarily on offline mobile development (on the road) so a quick setup of required services/applications should be possible and the amount of resource overhead should be minimal. But of course the whole thing will be deployed/published at some point so i dont want to obstruct that if both can be managed
  • development is done on windows and linux host machines
  • access to all services from host machine is required for development purposes

What i am trying to achieve is to have a docker-compose.yaml file in the application repositories which i invoke via docker-compose up which would then start all required containers if not running already, e.g. the database container is started when i invoke docker-compose up in a backend application repository.

My approach was to have a new git repository which defines all shared docker images/containers, with its own docker-compose.yaml where all devs would have to run docker-compose build whenever something changed (might be automated with a git commit hook in the future). The central docker-compose.yaml looks like this

version: "3"
services:

  postgres:
    build: ./images/postgres
    image: MY-postgres
    container_name: MY-postgres-server
    ports:
      - "5432:5432"

  httpd:
    build: ./images/httpd
    image: MY-httpd
    container_name: MY-httpd-server
    ports:
      - "80:80"

The Dockerfile describing how each image is built is in its own subfolder and i think not relevant for the question, basically the default images for alpine + apache/postgres.

So the problem: how would a docker-compose.yaml in the application git repository look like that references the services/containers defined by the above central docker-compose.yaml.

Now since this is no new problem scenario, i did some research and honestly the variety of approaches and proposed solutions was confusing, for once the various versions and compatibilities, features that were deprecated, etc.

Wow, that escalated quickly. But i wanted to show the research i have done since i just cant believe that its currently not possible.

x29a
  • 1,761
  • 1
  • 24
  • 43
  • 1
    Please clarify what the actual question is. We have the context, general aim but no specific problem. Are you struggling with writing `docker-compose.yml` that works? Or are you wondering where to place this docker-compose file (separate repo vs copies in each microservice repo)? Or are you wondering about data persistence specifically? If it's the latter you need to bind-mount DB data dir into the container: `volumes`: `- ./db_data/lib/postgresql:/var/lib/postgresql` `- ./db_data/log/postgresql:/var/log/postgresql` `- ./db_data/etc/postgresql:/etc/postgresql` – rszalski Jan 18 '18 at 04:44
  • @szalski thanks for responding. i clarified a bit more what im struggling with, its the first. Volumes were only mentioned a couple of times in similar scenarios so i assumed they might be a possible solution yet i have absolutely no idea how. – x29a Jan 18 '18 at 04:47

0 Answers0