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
You need to run it with -d flag to leave it running as daemon in the background.
docker run -d -it ubuntu bash