简体   繁体   中英

docker - multiple projects on one Dockerfile and docker-compose.yml

I'm starting with Docker and in my opinion is great! Now I'm looking solution for this organization:
Now I have this structure:

Applications
| +--app1
| |  +--node_modules   
| |  +--package.json  
| |  +--...  
| +--app2  
| |  +--node_modules
| |  +--package.json  
| |  +--...  
| ....   
| docker-compose.app1.yml
| docker-compose.app2.yml
| ....
| Dockerfile  //my personalized image for all projects

But I want reach this:

Applications
| +--app1  
| |  +--node_modules //empty in host  
| |  +--package.json  
| |  +--docker-compose.app1.yml  //override compose
| |  +--...  
| +--app2  
| |  +--node_modules  //empty in host  
| |  +--package.json  
| |  +--...  
| ....  
| +--node_modules //global node_modules folder (linked to projects)  
| docker-compose.yml //principal compose  
| Dockerfile  //my personalized image for all projects

I thinking too about create one global "server" and link all projects on VHosts but how I'll get access to each of project?

You are looking for docker-comopose extends. Thas permits you override previus configurations.

web: 
    extends: file: common-services.yml
    service: webapp

See full documentation in : https://docs.docker.com/compose/extends/#extending-services

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM