Several projects, several docker-compose files, HOW?


I have a question:
For example i have two applications A and B. Both projects have their own docker-compose.yml configurations. Both have such containers like nginx and mysql. So, could i reuse mysql/nginx containers in both docker-compose configs without recreating containers for each project (i need to use SAME containers with same data)?

is it really good to reuse containers? Could you just reuse your images instead?

for example, i need to have access to one db from different projects

could one of the composes be the root one?
If so, could you use external links?

1 Like

In this case i need to support n+1 configurations and create one more project for root docker-compose, it’s not good.

Hey there, in case you deploy it as docker services (using docker stack deploy), you could define an external network.
By doing so, your DB container could be attached to multiple external networks. One network for service A and one network for service B.
For this you might even use three dockerfiles: db.yml, service1.yml and service2.yml.
If service 1 and 2 are similar and only differ in the environment variables, you might even use different env-files.