Search code examples
dockerdocker-composedockerfiledocker-machine

can anyone let me know what is the issue in my docker file?


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


Solution

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

    Reference CMD

    Reference ENTRYPOINT