Run multiple daemon in same container


Is there a way to run multiple daemons in same container ? I’d like to run crond, apache and postfix
in the same container but for example when I try to launch crond using RUN crond, it doesn’t start. For apache no problem because de last action in my dockerfile is the CMD to launch httpd.

The docker version is 1.9.1

Thanks in advance for your helps.

RUN only run it once while building the docker images. and you can only specify 1 entry point and 1 cmd

there are 2 solutions:

  1. write a bash script that run 2 commands, and use entrypoint/cmd to call this script
  2. create one docker container for each, and link them together. you may want to look at docker-compose for this.

Ok. Thanks. I will try it right now :smile:

Be sure to run crond with the -n flag so it runs in the foreground. All processes inside a container must run in the foreground otherwise they will exit.

try docker exec. It can start another process in a container.