Start a Docker Container with Multiple Bash Command Execution

Start a docker container and launch multiple background process (service) through docker run is impossible. The reason is that docker run does not support multiple command given as docker run argument. Multiple command execution is only viable through /bin/bash -c "command1; command2". However, a container is by design exited whenever the /bin/bash process is finished. Because of this mechanism, all service launching command like "python" must not ended with a daemon decorator "&", such as /bin/bash -c "python & python &" (In this case, the /bin/bash process finishes so that the container then exited").

Theoretically, a command such as /bin/bash -c "python & python" should bypass this problem since /bin/bash process got stuck with the process running in the foreground (within the container)", but this proved to be wrong in practice due to unknown reasons".

It is worth to mention that commands such as /bin/bash -c "python; python" will keep the container running, but the launch of will prevent from launching forever (because of the ; decorator).

1. /bin/bash -c "command1; command2" is rarely useful
2. docker run xxx /bin/bash -c "command" can be replaced by docker run xxx command
3. Multiple services should be split into different containers/images (container and service should maintain 1-on-1 mapping)