liveBook · Manning

Dockerfile

As explained in Kubernetes in Action, Second Edition

A Dockerfile is a text configuration file containing instructions for building a Docker container image.

A Dockerfile is a text file containing instructions that Docker performs to build a container image. It packages an application and its dependencies so the resulting image can run locally or with Kubernetes. section 2.2.2 section 2.4

A minimal Dockerfile typically establishes the image foundation, adds application files, and defines the startup command:

  • FROM selects the base image; here, node:23-alpine supplies the Node.js runtime. section 2.2.2
  • COPY transfers app.js and the html directory from the local build context into the image. section 2.2.2
  • ENTRYPOINT defines the command Docker runs when the container starts: node app.js. section 2.2.2
Listing 2.1 A minimal Dockerfile for building a container image
FROM node:23-alpine      #1
COPY app.js /app.js       #2
COPY html/ /html      #3
ENTRYPOINT ["node", "app.js"]      #4

Use the minimal Dockerfile listing to see how base-image selection, file copying, and startup behavior fit together. section 2.2.2

Build an image from a Dockerfile

With the Dockerfile, app.js, and html directory in the current directory, run docker build -t kiada:latest .. Docker resolves the node:23-alpine base image, executes the COPY instructions, exports image layers, and names the result kiada:latest. docker images lists the image, while docker history shows the instructions and layers that produced it. section 2.2.2 section 2.2.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains base images, file copying, startup commands, image layers, and build output through one minimal example.
Examples
Uses a Node.js application with app.js and html files, then demonstrates docker build, docker images, and docker history.
What it assumes
Assumes Docker is installed and application files are available, while explaining base images and image construction from the beginning.
What you can do after
Build it from scratch with Docker, tag the resulting image, and inspect its contents and construction history.
How it connects
Connects Dockerfiles with container images, base images, containers, image layers, container registries, and Kubernetes.

Also explained in

Compare how 18 books explain Dockerfile →

Related concepts

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