About
To run multiple services in a single container there are multiple ways
- with a basic script
- via a process manager
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:
- and the fg (foreground utility)
#!/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
- Docker and the overmind procfile manager
ADD Procfile /app/
CMD overmind start