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 web.py" must not ended with a daemon decorator "&", such as /bin/bash -c "python web1.py & python web2.py &" (In this case, the /bin/bash process finishes so that the container then exited").
Theoretically, a command such as /bin/bash -c "python web1.py & python web2.py" should bypass this problem since /bin/bash process got stuck with the web2.py 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 web1.py; python web2.py" will keep the container running, but the launch of web1.py will prevent web2.py 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)