I started studying docker containers and want to be told what I am wrong about. There is a web application that includes a database, a parser of other sites and routing with distribution of API to users. The question is whether it will be right to make three containers in this way:

  1. There will be a database at port 27017,
  2. One Express application on port 3000 that connects to the database on port 27017, in which there will be only one route for the parsing page http://localhost:3000/parse is hosted by Some kind of admin panel.
  3. Another Express application on port 5000, where there will be a routing for users and and delivery of data to users via an API that will be taken from the database on port 27017

And collect the whole thing through docker-compose.

Perhaps I misunderstood the concept, because there is not so much information, basically all the guides end up connecting the application and database in different containers, but there are simply no more complicated examples. But as far as I understand, a separate Node.js application is hosted in each container, but they all communicate on the same domain name at different ports. Correct or give some advice please.

    1 answer 1

    It is a working decision. If you want everything to be available on port 80, then you need to install nginx and configure routes. For example, api.domain.ru will refer to port 5000, and just domain.ru will issue what you have on port 3000.

    In my opinion, it is not worth dividing applications into two, since the functionality that you describe can be done in one application. You can use http://pm2.keymetrics.io/ to manage applications.