简体   繁体   中英

How should I combine docker containers?

I have a web app that I'm building composed of 3 different parts

  1. Node.js API
  2. Front end web client, consumes API
  3. Node.js service for data processing

I need the 2 node.js services to communicate so I am using rabbitMQ. I want everything to be dockerized because it makes on-boarding and deployment easy. However, I am not sure how to structure the files?

All 3 items should be in separate github repos so you can develop them individually, and for organization in general. One giant repo would be a nightmare.

But then how do I combine them at runtime? Should they each be in their own container? How do I pull them together?

Should they all be in one giant folder?

  • App
    • node1
      • dockerfile
    • node2
      • dockerfile
    • docker-compose.yml

Should they each be in their own container?

Yes, you declare them in a docker-compose.yml similar to this one , except I would recommend using theversion 2 of that docker-compose.yml format (that supposes Compose 1.6.0+ and a Docker Engine of version 1.10.0+).

That allows for named volumes and network .

As the OP adds in the comments:

The part I was missing was to upload my separate repos to dockerhub

If each repo represents a docker image, said image, once built, must indeed be uploaded to the docker hub.

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