0

i need a container running with java installed in it and i want to expose the port 8090.

Here is the Docker file i have written to achieve this.

FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive

ENV VERSION 8
ENV UPDATE 152
ENV BUILD 16
ENV SIG aa0333dd3019491ca4f6ddbe78cdb6d0

ENV JAVA_HOME /usr/lib/jvm/java-${VERSION}-oracle

# install jre
RUN apt-get update -qq && \
  apt-get upgrade -qqy --no-install-recommends && \
  apt-get install curl unzip bzip2 -qqy && \
  mkdir -p "${JAVA_HOME}" && \
        curl --silent --location --insecure --junk-session-cookies --retry 3 \
          --header "Cookie: oraclelicense=accept-securebackup-cookie;" \
          http://download.oracle.com/otn-pub/java/jdk/"${VERSION}"u"${UPDATE}"-b"${BUILD}"/"${SIG}"/jre-"${VERSION}"u"${UPDATE}"-linux-x64.tar.gz \
        | tar -xzC "${JAVA_HOME}" --strip-components=1 && \
  apt-get remove --purge --auto-remove -y curl unzip bzip2 && \
  apt-get autoclean && apt-get --purge -y autoremove && \
  rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN update-alternatives --install "/usr/bin/java" "java" "${JAVA_HOME}/bin/java" 1 && \
        update-alternatives --install "/usr/bin/javaws" "javaws" "${JAVA_HOME}/bin/javaws" 1 && \
        update-alternatives --set java "${JAVA_HOME}/bin/java" && \
        update-alternatives --set javaws "${JAVA_HOME}/bin/javaws"

EXPOSE 8090

Using the Dockerfile i was able to successfully build the image and i have pushed to my account in hub.docker.com

but when i run try to run the container using the following command , The Container was not running.

i broked my head analyzing the root cause more than 2 hours i was not able to find the problem.

I know i am missing something silly, can anyone have a look and point the mistake i am doing?

Thanks in advance

Vishnu Ranganathan
  • 1,277
  • 21
  • 45
  • 1
    Can you post the command you are using to run the container? – Héctor Nov 03 '17 at 12:39
  • 1
    And also post the exact error message you are getting. – Henry Nov 03 '17 at 12:40
  • 1
    Why are you creating your own image if you want Java? Why not use a pre-built image? E.g.: https://hub.docker.com/r/isuper/java-oracle/tags/ If there are certain reasons for creating your own, you might find [their dockerfile](https://hub.docker.com/r/isuper/java-oracle/~/dockerfile/) – k0pernikus Nov 03 '17 at 12:42
  • 2
    Sorry, first link was deprecated: https://hub.docker.com/r/sgrio/java-oracle/ – k0pernikus Nov 03 '17 at 12:43
  • @k0pernikus As per you input i tried to use the images in the link . docker run --name docjavaapp1234 sgrio/java-oracle:jre_8_unlimited . even this didnt bring my containers up. can you please verify iwheather it works for you ? – Vishnu Ranganathan Nov 03 '17 at 13:06
  • I don't use that java image myself. My comment was supposed to be a pointer to look up pre-existing images on docker hub. You could ask a new question about getting a certain image to run in a specific way. – k0pernikus Nov 03 '17 at 20:58

2 Answers2

2

Your Dockerfile is missing an ENTRYPOINT or CMD instruction. They define what command is run when starting the container.

Reference CMD

Reference ENTRYPOINT

samprog
  • 2,454
  • 1
  • 13
  • 18
  • Thanks for the quick response samprog , i added ENTRYPOINT ["/bin/bash"] and builded again still same issue . what else may be the issue ? – Vishnu Ranganathan Nov 03 '17 at 13:15
  • 2
    The container runs as long as the process you've started with the ENTRYPOINT or CMD instruction exists. If the process stops, the container stops. /bin/bash is not really a daemon or process that's continuously running. What service do you want to be reached on port 8090? I suggest you change your ENTRYPOINT or CMD to the command that starts said service. – samprog Nov 03 '17 at 13:26