liveBook · Manning

Dockerfile instruction

As explained in Kubernetes in Action, Second Edition

A Dockerfile instruction is a declarative command that specifies one step in building a container image.

A Dockerfile instruction is a declarative command that specifies one step in building a container image. Docker reads the Dockerfile from the build context and processes its instructions through the Docker daemon. 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

A minimal Dockerfile combines FROM to select a base image, COPY to add application files, and ENTRYPOINT to define the container process. section 2.2.2

During a build, Docker pulls the base image when needed, creates a temporary container, executes the next instruction, and records the resulting state as an image layer. Processing continues until the final image is tagged. section 2.2.2

Building an image

Run docker build -t kiada:latest . from the directory containing the Dockerfile and application files. The dot supplies the build context; afterward, docker images lists the tagged image and docker history shows instruction-derived layers. section 2.2.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains base-image pulls, temporary containers, image layers, and tagging, but gives syntax detail only through one minimal example.
Examples
Uses FROM, COPY, and ENTRYPOINT in a minimal Node.js Dockerfile, then illustrates build output and image history.
What it assumes
Assumes a Dockerfile and build context while introducing how the Docker CLI, daemon, base image, and layers cooperate.
What you can do after
Builds a tagged image with docker build and inspects it with docker images or docker history.
How it connects
Connects Dockerfile instructions with build contexts, base images, containers, image layers, the Docker daemon, and image tags.

Also explained in

Compare how 3 books explain Dockerfile instruction →

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.