acmoune
acmoune

Reputation: 3411

How to run multiples services in parallel in a single Docker container?

Let's say I have 3 services, service1, service2 and service3. To save money and keep the deployment simple I plan to run them in a single Docker container, instead of one for each. How can I define my ENTRYPOINT ?

If I run them in the background:

ENTRYPOINT service1 & service2 & service3 &

the command will exit, and so will my Container do.

If I run them sequentially:

ENTRYPOINT service1 && service2 && service3

or

ENTRYPOINT service1; service2; service3

service1 it will block, and service2 will start only after service1 will stop running.

I even tried with GNU parallel:

ENTRYPOINT (service1; service2; service3) | parallel

But same behavior, service2 starts only after service1 is stopped

So how can I have the 3 services running concurrently as one service, so my Container will only exit when all services are stopped ?

Upvotes: 1

Views: 1299

Answers (1)

Walter A
Walter A

Reputation: 19982

(first proposed as a comment) Start the services in the background and keep the docker container alive:

service1& service2& service3& wait

Upvotes: 2

Related Questions