title: Jersey Grizzly HTTP Server shutdown inside container docker
body: <p>I am trying to execute a Grizzly HTTP Server inside a container.</p>
  
  <p>My problem is that when I am running the container (using docker-compose) the container shuts down after a few seconds.</p>
  
  <p>Here is my server <strong>Dockerfile</strong>: </p>
  
  <pre class="lang-none prettyprint-override"><code>FROM alpine:3.5
  
  MAINTAINER Maybe One &lt;maybe@maybe.com&gt;
  
  # Java Version and other ENV
  ENV JAVA_VERSION_MAJOR=8 \
      JAVA_VERSION_MINOR=102 \
      JAVA_VERSION_BUILD=14 \
      JAVA_PACKAGE=jdk \
      JAVA_JCE=standard \
      JAVA_HOME=/opt/jdk \
      PATH=${PATH}:/opt/jdk/bin \
      GLIBC_VERSION=2.23-r3 \
      LANG=C.UTF-8
  
  RUN apk upgrade --update &amp;&amp; \
      apk add --update libstdc++ curl ca-certificates bash &amp;&amp; \
      for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION} glibc-i18n-${GLIBC_VERSION}; do curl -sSL https://github.com/andyshinn/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done &amp;&amp; \
      apk add --allow-untrusted /tmp/*.apk &amp;&amp; \
      rm -v /tmp/*.apk &amp;&amp; \
      ( /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true ) &amp;&amp; \
      echo "export LANG=C.UTF-8" &gt; /etc/profile.d/locale.sh &amp;&amp; \
      /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib &amp;&amp; \
      mkdir /opt &amp;&amp; \
      curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/java.tar.gz \
        http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_PACKAGE}-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz &amp;&amp; \
      gunzip /tmp/java.tar.gz &amp;&amp; \
      tar -C /opt -xf /tmp/java.tar &amp;&amp; \
      ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} /opt/jdk &amp;&amp; \
      if [ "${JAVA_JCE}" == "unlimited" ]; then echo "Installing Unlimited JCE policy" &gt;&amp;2 &amp;&amp; \
        curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/jce_policy-${JAVA_VERSION_MAJOR}.zip \
          http://download.oracle.com/otn-pub/java/jce/${JAVA_VERSION_MAJOR}/jce_policy-${JAVA_VERSION_MAJOR}.zip &amp;&amp; \
        cd /tmp &amp;&amp; unzip /tmp/jce_policy-${JAVA_VERSION_MAJOR}.zip &amp;&amp; \
        cp -v /tmp/UnlimitedJCEPolicyJDK8/*.jar /opt/jdk/jre/lib/security; \
      fi &amp;&amp; \
      sed -i s/#networkaddress.cache.ttl=-1/networkaddress.cache.ttl=30/ $JAVA_HOME/jre/lib/security/java.security &amp;&amp; \
      apk del curl glibc-i18n &amp;&amp; \
      rm -rf /opt/jdk/*src.zip \
             /opt/jdk/lib/missioncontrol \
             /opt/jdk/lib/visualvm \
             /opt/jdk/lib/*javafx* \
             /opt/jdk/jre/plugin \
             /opt/jdk/jre/bin/javaws \
             /opt/jdk/jre/bin/jjs \
             /opt/jdk/jre/bin/orbd \
             /opt/jdk/jre/bin/pack200 \
             /opt/jdk/jre/bin/policytool \
             /opt/jdk/jre/bin/rmid \
             /opt/jdk/jre/bin/rmiregistry \
             /opt/jdk/jre/bin/servertool \
             /opt/jdk/jre/bin/tnameserv \
             /opt/jdk/jre/bin/unpack200 \
             /opt/jdk/jre/lib/javaws.jar \
             /opt/jdk/jre/lib/deploy* \
             /opt/jdk/jre/lib/desktop \
             /opt/jdk/jre/lib/*javafx* \
             /opt/jdk/jre/lib/*jfx* \
             /opt/jdk/jre/lib/amd64/libdecora_sse.so \
             /opt/jdk/jre/lib/amd64/libprism_*.so \
             /opt/jdk/jre/lib/amd64/libfxplugins.so \
             /opt/jdk/jre/lib/amd64/libglass.so \
             /opt/jdk/jre/lib/amd64/libgstreamer-lite.so \
             /opt/jdk/jre/lib/amd64/libjavafx*.so \
             /opt/jdk/jre/lib/amd64/libjfx*.so \
             /opt/jdk/jre/lib/ext/jfxrt.jar \
             /opt/jdk/jre/lib/ext/nashorn.jar \
             /opt/jdk/jre/lib/oblique-fonts \
             /opt/jdk/jre/lib/plugin.jar \
             /tmp/* /var/cache/apk/*
  
  # Maven
  ENV MAVEN_VERSION 3.3.9
  ENV MAVEN_HOME /usr/lib/mvn
  ENV PATH $MAVEN_HOME/bin:$PATH
  
  RUN wget http://ftp.fau.de/apache/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz &amp;&amp; \
      tar -zxvf apache-maven-$MAVEN_VERSION-bin.tar.gz &amp;&amp; \
      rm apache-maven-$MAVEN_VERSION-bin.tar.gz &amp;&amp; \
      mv apache-maven-$MAVEN_VERSION /usr/lib/mvn
  
  # Workspace
  ENV WORKSPACE /home/app/
  
  RUN mkdir -p $WORKSPACE
  WORKDIR $WORKSPACE
  
  COPY . $WORKSPACE             # Copy Server Project
  RUN mvn clean install -DskipTests
  
  ENTRYPOINT mvn exec:java
  </code></pre>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre class="lang-yaml prettyprint-override"><code>version: '2.1'
  services:
    server:
      build: ./server/
      ports:
        - "8080:8080"
  </code></pre>
  
  <p><strong>server docker logs</strong>:</p>
  
  <pre class="lang-none prettyprint-override"><code>... maven...
  [INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ restful.littleapp ---
  Jan 30, 2017 2:10:18 PM org.glassfish.grizzly.http.server.NetworkListener start
  INFO: Started listener bound to [0.0.0.0:8080]
  Jan 30, 2017 2:10:18 PM org.glassfish.grizzly.http.server.HttpServer start
  INFO: [HttpServer] Started.
  Jersey app started with WADL available at http://0.0.0.0:8080/littleapp/application.wadl
  Hit enter to stop it...
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 5.507 s
  [INFO] Finished at: 2017-01-30T14:10:18+00:00
  Jan 30, 2017 2:10:18 PM org.glassfish.grizzly.http.server.NetworkListener shutdownNow
  INFO: Stopped listener bound to [0.0.0.0:8080]
  [INFO] Final Memory: 37M/90M
  [INFO] ------------------------------------------------------------------------
  </code></pre>
  
  <p>Normally, the server has to listen...</p>