liveBook · Manning

Docker

As explained in Road to Kubernetes

Docker is a software platform and command-line tool for building, distributing, and running applications in containers.

Docker provides tools to build, share, and run applications in containers. A container bundles an application with its dependencies, making it easier to move between machines. Docker is a common choice for this work, but it is not the only way to build or run containers. section 1.4

Start with a Dockerfile: a reusable configuration file for building a container image. A container builder turns that file and your application code into an image. A registry stores images for sharing; a container runtime runs them. This separates preparing an application from running it on a server. section 1.1 section 1.4

Listing 1.1 Dockerfile
FROM python:3.10
COPY . /app
WORKDIR /app
RUN python3 -m pip install pip --upgrade && \
    python3 -m pip install --no-cache-dir -r requirements.txt
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "main:app"]

This short Dockerfile uses Python 3.10, copies application code, installs requirements, and specifies a command to start the application. section 1.4

Run NGINX locally

Install Docker Desktop and check it with `docker --version`. Then run `docker run nginx`. If the image is not on your machine, Docker pulls it from Docker Hub, its default container registry. The container runs, but visiting its web page requires additional options to publish a port. section 5.1 section 5.1.1

Run NGINX on an Ubuntu virtual machine

Install Docker Engine on the VM, then run `docker run -d --restart always --name my-nginx -p 80:80 nginx`. The `-d` flag runs the container in the background. Use `docker ps` to find running containers, `docker logs my-nginx` to inspect output, and `docker stop my-nginx` to stop it. section 7.1.2 section 7.1.4

On a production VM, Docker Engine can replace separate installations of application runtimes such as Python and Node.js. Docker Compose is installed separately as a plugin there and can run a containerized application from its configuration. GitHub Actions can install both tools over SSH as part of deployment automation. section 7.0 section 7.1.3 section 7.3.2

Docker is not synonymous with every container runtime. Docker Compose uses Docker Engine; Kubernetes runs containers with containerd by default. Container images remain useful when moving toward Kubernetes, although different processor platforms can require separate images. section 7.1.2 section 8.0 section 8.1.3

How Road to Kubernetes covers it

How deep it goes
Works through installation, image retrieval, container commands, VM deployment, and automated setup; defers hosting a private registry.
Examples
Uses a Python 3.10 Dockerfile and NGINX commands for local runs and Ubuntu VM deployment.
What it assumes
Starts with Docker Desktop installation and a version check; explains the additional Docker Engine and Compose installation needed on an Ubuntu VM.
What you can do after
Operate/configure it to run and inspect containers locally or on an Ubuntu VM, then automate VM setup with GitHub Actions.
How it connects
Connects Dockerfiles and container registries to images, then Docker Compose and container runtimes to deployment and Kubernetes.

Also explained in

Compare how 26 books explain Docker →

Related concepts

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