I run a container in the background using
docker run -d --name hadoop h_Service
it exits quickly. But if I run in the foreground, it works
My pracitce is in the Dockerfile start a shell which will not exit immediately CMD [ "sh", "-c", "service ssh start; bash"], then run docker run -dit image_name. This way the (ssh) service and container is up running.
CMD [ "sh", "-c", "service ssh start; bash"]
docker run -dit image_name