Running multiple servers with docker images

I have three express servers written on nodes. These servers serve different purposes and, therefore, operate on different ports.

For example: app1.js at 8000, app2.js at 5000 and app3.js at 5432.

I want to create a docker image using a docker file and start all these servers. Can we do this? If so, how can we do this? According to my information, we can only run one command from a docker file.

+6
source share
4 answers

You might want to explore Docker Compose .

Each server will have its own Docker file, and your docker-compose.yml file will determine the ports that they open and how they interact.

+5
source

The proposed Ethan mechanism is correct for launching several docker containers at once, but does not explain why.

To explain a little further, each docker container can spawn several processes (servers), but for a docker container one of the processes is required, which should be in the foreground, and docker - the container’s life cycle usually reflects the life cycle of the foreground process.

Many of the benefits of docking will be lost when running all processes in the same docker container. And therefore, it is recommended that you have one docker container per process.

+3
source

Until it is "recommended", you can do it. It is even documented.

Docker and Supervisor

Or you can use runit

I have been using s6 recently

+2
source

You can check phusion user nodejs image . You can configure it to run a single server serving data from several nodejs processes.

0
source

All Articles