liveBook · Manning

Container image

As explained in Kubernetes for Developers

A Docker image is an immutable package containing a filesystem, application code, dependencies, and metadata used to create a Docker container.

A container image packages a filesystem, application code, dependencies, and configuration into a reusable artifact. Docker creates a container instance from that image; the instance runs the image’s process and can be stopped or recreated. section 2.1.2 section 2.4

Build an image when an application must run consistently across machines. A Dockerfile records procedural build instructions: choose a base image, install the required language and operating-system dependencies, copy the application, select its working directory, and define its command. section 2.1.3 section 2.1.6

The practical image workflow is:

  • Start from a suitable base image, such as Ubuntu or a Python image. section 2.1.2 section 2.1.6
  • Install dependencies during the build, including language packages, database clients, fonts, or TLS certificates. section 2.1.6
  • Copy application files into the image and build it with Docker. section 2.1.3
  • Run the resulting image to create an ephemeral container instance; local Docker users can restart stopped instances or remove unused artifacts. section 2.1.2

A repeatable Python image

A Dockerfile can use Ubuntu, install Python, copy a small application into /app, and set that directory as the working directory. Building it as hello and running `docker run hello python3 hello.py` produces `Hello Docker` without installing Python on the local system. section 2.1.3

Listing 2.2 Chapter02/2.1.3_Dockerfile/Dockerfile
FROM ubuntu                      #1
RUN apt-get update               #2
RUN apt-get install -y python3   #2
COPY . /app                      #3
WORKDIR /app                     #4

Inspect the Dockerfile that turns a base operating system, Python installation, and application files into an image. section 2.1.3

How Kubernetes for Developers covers it

How deep it goes
Explains image construction through Dockerfiles, dependencies, and runtime instances, while only summarizing multistage builds.
Examples
Uses Ubuntu and Python or Ruby images, a Hello Docker script, database clients, fonts, and Docker build-and-run commands.
What it assumes
Starts with interactive Docker commands and teaches images, containers, Dockerfiles, and dependency installation from basic examples.
What you can do after
Build it from scratch with a Dockerfile, install dependencies, run the image, and manage resulting local container instances.
How it connects
Connects container images with Dockerfiles, base images, dependencies, container instances, Docker Compose, and Kubernetes.

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 Kubernetes for Developers. The section links point to the parts of the book it draws on.