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 it works...

You define the container structure and its contents by defining Dockerfile. Dockerfile follows a structure, where each line is of the form, INSTRUCTION arguments. There is a predefined set of instructions, namely FROM, RUN, CMD, LABEL, ENV, ADD, COPY, and others. A complete list can be found at https://docs.docker.com/engine/reference/builder/#from. Let's look at our defined Dockerfile:

FROM ubuntu:17.10FROM openjdk:9-b177-jdkVOLUME /tmpADD target/boot_docker-1.0.jar restapp.jarENV JAVA_OPTS="-Dspring.profiles.active=cloud"ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar /restapp.jar" ]

The first two lines using the FROM instruction specified the base image for our Docker image. We use the Ubuntu OS image as the base image and ...

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