Dockerfile for elementary Hello World.java



  • If you use a ready container with Java: Here's Dockerfile:

    FROM java:7
    COPY . /src
    WORKDIR /home/alexkup/Dropbox/HW/02/src
    RUN javac Hellodocker.java
    CMD ["java", "Hellodocker"]
    

    What gives me:

    lexkup@alexkup-SVE1511N1RW:~/Dropbox/HW/02$ sudo docker build -t alexkup/hellodocker /home/alexkup/Dropbox/HW/02
    Sending build context to Docker daemon   105 kB
    Step 1 : FROM java:7
     ---> e93dd201a77e
    Step 2 : COPY . /src
     ---> Using cache
     ---> ecd81ca38846
    Step 3 : WORKDIR /home/alexkup/Dropbox/HW/02/src
     ---> Using cache
     ---> 248957b17db1
    Step 4 : RUN javac Hellodocker.java
     ---> Running in f9faa6229355
    javac: file not found: Hellodocker.java
    Usage: javac <options> <source files>
    use -help for a list of possible options
    The command '/bin/sh -c javac Hellodocker.java' returned a non-zero code: 2
    

    Can't find Hellodocker.java? Here's the way. /home/alexkup/Dropbox/HW/02/src

    Road to Dockerfile /home/alexkup/Dropbox/HW/02

    Tell me what line I'm not writing right. Or what could be the problem? Thank you.



  • Or use it now. https://hub.docker.com/_/java/ and not ubuntu:14.04:

    FROM java:7
    # ./myapp - директория на локальной машине с приложением
    COPY ./myapp  /usr/src/myapp
    WORKDIR /usr/src/myapp
    RUN javac Hellodocker.java
    CMD ["java", "Hellodocker"]
    

    Either in the container's bill, put Java on your own:

    FROM ubuntu:14.04
    

    MAINTAINER Alex Kuptsov <alex.kuptsov@gmail.com>

    Install all prerequisites

    RUN apt-get -y install software-properties-common
    RUN apt-get -y update
    RUN
    echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections &&
    add-apt-repository -y ppa:webupd8team/java &&
    apt-get update &&
    apt-get install -y oracle-java8-installer &&
    rm -rf /var/lib/apt/lists/* &&
    rm -rf /var/cache/oracle-jdk8-installer

    Define commonly used JAVA_HOME variable

    ENV JAVA_HOME /usr/lib/jvm/java-8-oracle

    COPY ./myapp /usr/src/myapp
    WORKDIR /usr/src/myapp

    RUN javac Hellodocker.java

    CMD ["java", "Hellodocker"]


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2