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





Discover More
Card Puncher Data Processing
What is the ENTRYPOINT docker instruction?

ENTRYPOINT is a docker instruction that defines the default docker entrypoint It has two different behavior that depends on the assignment format. ENTRYPOINT has the following forms: Command line...
Card Puncher Data Processing
What is the Entrypoint (Main) in Docker?

This page is the main entry in Docker. The entry point script is the command (or script) called when creating a container from an image with the docker run command When the entry point program exits,...



Share this page:
Follow us:
Task Runner