Keep HTTP server running

I have simple akka-http server. (Java) . I am able to keep the server running with System.in.read() as shown in the documentation. However the server immediately crashes when running on the docker container. Here is my code and relevant information. Any help will be really appreciated.

final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = application
                                                                    .route(createIngestionRoutes(),
                                                                            createHealthRoutes(),
                                                                            createResourceRoutes())
                                                                    .flow(actorSystem, materializer);
        final CompletionStage<ServerBinding> binding = http.bindAndHandle(routeFlow,
                                                            ConnectHttp.toHost("0.0.0.0", 8080),
                                                            materializer);
        //binding.toCompletableFuture().get();
      //  System.out.println("Server online at http://localhost:8010/\nPress RETURN to stop...");
       System.in.read(); // let it run until user presses return

DOCKERFILE:

FROM openjdk:8-jre
ADD jar-all.jar /app/app.jar
EXPOSE 8010 19999 2552 8080
WORKDIR /app
ENTRYPOINT ["java", "-jar", "/app/app.jar"]

akka-cluster.yml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: appname
  name: appname
spec:
  replicas: 3
  selector:
    matchLabels:
      app: appname
  template:
    metadata:
      labels:
        app: appname
        actorSystemName: actor-system
    spec:
      containers:
      - name: appname
        image: imagename:2.0
        imagePullPolicy: Never
        env:
        - name: HOST_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: status.podIP
        - name: NETWORK_HOST
          value: _eth0_
        livenessProbe:
          tcpSocket:
            port: 19999
          initialDelaySeconds: 60
        ports:
        # akka remoting
        - name: remoting
          containerPort: 2552
          protocol: TCP
        # akka-management bootstrap
        - name: bootstrap
          containerPort: 8010
          protocol: TCP
        # external http
        - name: akka-mgmt-http
          containerPort: 19999
          protocol: TCP
---
kind: Service
apiVersion: v1
metadata:
  name: servicename-service
spec:
  clusterIP: None
  selector:
    app: appname
  ports:
  - protocol: TCP
    port: 8010
    targetPort: 8010

Hi Arun,

I would suspect it is because there is no std in available when running within the docker container.

You can either use HttpApp (https://doc.akka.io/docs/akka-http/current/routing-dsl/HttpApp.html) or just look what it is done there: https://github.com/akka/akka-http/blob/78e5b1fad23e8e434cf7fd78147547f76cb88c4f/akka-http/src/main/java/akka/http/javadsl/server/HttpApp.java#L168
In essence, is getting a Future from a Promise that is completed when JVM is shutdown. I guess this might work.