liveBook · Manning

Build context

As explained in Kubernetes in Action, Second Edition

A build context is the set of files and directories supplied to Docker for building a container image.

A build context is the set of files and directories Docker receives for building a container image. With `docker build -t kiada:latest .`, the final dot selects the current directory as the context. section 2.2.2

Building from the current directory

Place the Dockerfile, `app.js`, and the `html` directory in one directory, then run `docker build -t kiada:latest .`. Docker reads the Dockerfile and uses the directory's contents while producing the tagged image. section 2.2.2

The Docker CLI uploads the entire context to the Docker daemon, which performs the build. The daemon may run locally, inside a Linux virtual machine, or on a remote computer. section 2.2.2

Use the context deliberately:

  • Keep unnecessary files out of the build directory because uploading them can slow builds, especially with a remote daemon. section 2.2.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains directory selection, daemon upload, remote-daemon implications, and performance impact without detailing context filtering internals.
Examples
Demonstrates `docker build -t kiada:latest .` with `app.js`, an `html` directory, and a minimal Dockerfile.
What it assumes
Assumes a Dockerfile and application artifacts are available in the selected directory.
What you can do after
Builds a tagged container image from a local directory using the Docker CLI.
How it connects
Connects build context with Dockerfile, Docker daemon, base image, and container image.

Also explained in

Compare how 2 books explain build context →

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.