liveBook · Manning

Docker

As explained in Spring in Action, Sixth Edition

The Docker runtime is the installed Docker software environment that builds and runs Docker images and containers.

Docker is a runtime environment for building and running images and containers. Container images package applications in a standard format that can run across cloud environments. section 18.3

A minimal Dockerfile packages a Spring Boot executable JAR:

  • FROM selects an image providing the OpenJDK 11 runtime. section 18.3
  • ARG identifies the project JAR with a wildcard, COPY places it in the image as app.jar, and ENTRYPOINT runs it. section 18.3

Build and run an image

From the project directory, run docker build . -t habuma/tacocloud:0.0.19-SNAPSHOT, then start the container with docker run -p8080:8080 habuma/tacocloud:0.0.19-SNAPSHOT. section 18.3

FROM openjdk:11.0.12-jre
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

Inspect the complete Dockerfile used to copy the built JAR and launch it with Java. section 18.3

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains Dockerfile instructions and build/run commands, while stopping short of deeper runtime internals.
Examples
Uses a Spring Boot JAR, an OpenJDK 11 Dockerfile, docker build, docker run, and port 8080 mapping.
What it assumes
Assumes a built executable JAR and teaches the Dockerfile steps needed to package and start it.
What you can do after
Operate Docker by building, running, tagging, and pushing a Spring Boot container image.
How it connects
Connects Docker with Dockerfile, container images, containers, executable JAR files, and Spring Boot.

Also explained in

Compare how 26 books explain Docker →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.