liveBook · Manning

Container image

As explained in Akka in Action, Second Edition

A Docker image is an immutable package containing an application, its dependencies, and the metadata needed to create a Docker container.

A container image packages an application JAR for deployment as a Docker container. For an Akka service, the image also records the runtime base image and the ports that Kubernetes must reach. Building it locally places a versioned image in the local Docker repository; Kubernetes can then create pods from an image available to the cluster. section 13.2.1 section 15.4

Create the image after configuring Kubernetes-based cluster discovery and Akka Management. The management endpoint binds to port 8558 on 0.0.0.0 so readiness and liveness probes can reach it; 0.0.0.0 makes the service listen on every available host interface. section 13.2.1

version := "0.1.0-SNAPSHOT"                        #1
enablePlugins(JavaAppPackaging, DockerPlugin)      #2
dockerExposedPorts := Seq(8558, 2552)              #3
dockerBaseImage := "adoptopenjdk:11-jre-hotspot"   #4

A minimal build enables Java application packaging and Docker support, assigns a version, exposes management and remote ports, and selects a Java 11 JRE base image. section 13.2.1

Build and publish an image in this order:

  • Enable JavaAppPackaging and DockerPlugin, set dockerExposedPorts and dockerBaseImage, and give the project a version. section 13.2.1 section 15.3.2
  • Run sbt docker:publishLocal to create a locally tagged image, or run the project publish task when preparing the betting-house deployment. section 13.2.1 section 15.3.2
  • For an external registry, log in, tag the local image with the registry repository name, and push it so Kubernetes can obtain it. section 13.2.1
  • Reference the image name in the Kubernetes deployment, alongside the service account, role binding, namespace, database, and other required cluster resources. section 13.2.1 section 15.4

Betting-house image

The betting-house service uses a Java 11 JRE base image and exposes ports for Akka Management, Akka Remote, entity services, and the bet-projection query. Its deployment.yml identifies the Docker image wrapping the application JAR; once the dependent database and cluster resources are ready, the deployment starts multiple pods from that image. section 15.3.2 section 15.4

The same application can run locally or in Kubernetes with nearly identical configuration. The notable cluster difference is local seed nodes versus Akka Cluster Bootstrap and Akka Management in Kubernetes; the image remains the deployment package for the JAR. section 15.4

How Akka in Action, Second Edition covers it

How deep it goes
Walks through plugin settings, ports, local publishing, registry tagging, pushing, and deployment use without detailing image internals.
Examples
Uses a minimal Java 11 image setup and a betting-house image exposing management, remote, service, and projection ports.
What it assumes
Assumes basic Kubernetes and database understanding while specifying the image-building plugins and deployment prerequisites.
What you can do after
Operate/configure it by building, tagging, publishing, and referencing an application image in a Kubernetes deployment.
How it connects
Connects DockerPlugin and JavaAppPackaging with Kubernetes Deployment, Akka Management, Akka Cluster Bootstrap, and service accounts.

Also explained in

Compare how 25 books explain container image →

Related concepts

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