O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Create Dockerfile at the root of the application with the following content:
      FROM ubuntu:17.10      FROM openjdk:9-b177-jdk      VOLUME /tmp      ADD target/boot_docker-1.0.jar restapp.jar      ENV JAVA_OPTS="-Dspring.profiles.active=cloud"      ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar /restapp.jar" ]
  1. Run the following command to build a Docker image using Dockerfile created in the preceding step:
      $ docker build --tag restapp-image .      Sending build context to Docker daemon 18.45 MB      Step 1/6 : FROM ubuntu:17.10      ---> c8cdcb3740f8      Step 2/6 : FROM openjdk:9-b177-jdk      ---> 38d822ff5025      Step 3/6 : VOLUME /tmp      ---> Using cache      ---> 38367613d375      Step 4/6 : ADD target/boot_docker-1.0.jar restapp.jar      ---> Using cache      ---> 54ad359f53f7 Step 5/6 : ENV ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required