liveBook · Manning

Docker

As explained in Kubernetes in Action, Second Edition

Docker is a platform and toolset for building, distributing, and running software containers.

Docker is a platform for packaging, distributing, and running applications in containers. It bundles an application with the files it needs, so the same image can be run on another computer without installing the application’s dependencies there. section 2.1.2

Three terms describe the basic workflow:

  • An image contains the application’s filesystem and metadata, including what to run. section 2.1.2
  • A registry stores images for sharing. You can push an image to a registry and pull it onto another computer. section 2.1.2
  • A container is created from an image. It runs as a process whose environment is isolated from the host and other processes. section 2.1.2

Run a first container

Install Docker Engine on Linux, or Docker Desktop on macOS or Windows. On Windows, configure Docker Desktop to use Linux containers. Then run `docker run busybox echo "Hello World"`. Docker pulls the image from Docker Hub if it is not available locally, starts the container, and prints `Hello World`. section 2.1.3

Package an application

A Dockerfile can start from `node:23-alpine`, copy an application into the image, and set its startup command: `FROM node:23-alpine` `COPY app.js /app.js` `COPY html/ /html` `ENTRYPOINT ["node", "app.js"]` Run `docker build -t kiada:latest .` to build the image, then `docker images` to check that it exists. This avoids installing Node.js locally just to run the application. section 2.2.2

Docker uses Linux kernel mechanisms for process isolation; Docker itself is not the source of that isolation. Its images can also be built with Docker and run by another OCI-compliant runtime. In Kubernetes, the Kubelet asks a compatible container runtime to run an assigned application instance; that runtime need not be Docker. section 2.1.4 section 1.2.4

For logs, containerized applications commonly write to standard output and standard error. Use `docker logs <container-id>` for a container run with Docker; use `kubectl logs` for a container in a Kubernetes pod. Keeping one main process per container also makes its output easier to identify. section 5.3.2 section 5.1.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains images, registries, and containers, then works through a Dockerfile and build command rather than Docker implementation internals.
Examples
Runs BusyBox to print a greeting and builds a Node.js application image from a minimal Dockerfile.
What it assumes
Starts with basic container concepts, then requires Docker Engine or Docker Desktop; Windows examples assume Linux containers.
What you can do after
Apply it via the Docker CLI to run an existing image, build an application image, and view container logs.
How it connects
Connects container images and registries to Kubernetes container runtimes, OCI standards, pods, and application logs.

Also explained in

Compare how 26 books explain Docker →

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.