How to start multiple processes in Docker?

Card Puncher Data Processing

About

To run multiple services in a single container there are multiple ways

Solutions

Script

With a script:

  • you start any number of programs in the background,
  • and you start a process at the end that stay in the foreground to keep the VM alive.

Example of script:

#!/bin/bash
set -m # to make job control work
/app/server &
/app/server -bar &
fg %1 

Docker file with the ENTRYPOINT instruction

ADD multiple.sh /app/
ENTRYPOINT /app/multiple.sh

Process Manager

A process manager can start more than one process.

Example with overmind

  • A Procfile with two commands:
web: bundle exec rails server -p $PORT
foo: /app/foo
ADD Procfile /app/
CMD overmind start







Share this page:
Follow us:
Task Runner