Can I extend files to create dockers?

I have three different projects, ProjectA depends on ProjectB, which in turn depends on ProjectC.

Suppose you want to develop only ProjectC, so I want to use the configuration with one container only at runtime.

ProjectB needs ProjectC, so I have to define a docker layout with two images.

ProjectA again needs ProjectB and ProjectC, so I'm afraid that I will either have to duplicate a lot in each docker-compose.yml , the longer the dependency chain gets.

I know that I can link external images in the docker-compose.yml file, but that means more manual configuration, since I have to check every project and run docker-compose.yml in each of them.

Basically, I am wondering how I can control the docker layout setup for microservice architecture.

Due to the lack of a better phrase: can I expand the docker-compose.yml files?

+1
source share
2 answers

The next version (1.5.0) will support a way to expand the composition (see https://github.com/docker/compose/pull/2051 ). Now it is in wizard mode if you want to try it.

I think that what you are describing is pretty close to this suggestion https://github.com/docker/compose/issues/318

+2
source

You can extend the services in the docker-compose.yml file from another YAML file. Just use the extends key in the docker-compose.yml file.

For instance:

projectC.yml

 webapp: build: . environment: - KEY=VALUE ports: - "8000:8000" 

projectB.yml

 web: extends: file: projectC.yml service: webapp 
+1
source

Source: https://habr.com/ru/post/1274728/


All Articles