Docker Knowledge
Kip Landergren
(Updated: )
My Docker knowledge base explaining how containerization integrates into a build and development process.
Contents#
Overview#
Docker is a tool for operating system level virtualization. An isolated area of the host system is created using cgroups and namespaces, and it is through these mechanisms that a container is run.
Core Ideas#
Builds Should Be Reproducible#
A Dockerfile should create an immutable image.
Apps Should Be Isolated#
From their host machines and have defined entry and exit points.
Scaling Should Be Easy#
Both up and down.
Key Concepts#
Operating System Level Virtualization#
Lightweight compared to Virtual Machines / Hypervisors, which allocate dedicated resources beyond what may be actually used.
Terminology#
- container#(term container)
- 1.
A runnable instance of an image.
Related:
- container, service, stack#(term container, service, stack)
- 1.
How docker describes app building, from bottom of hierarchy to the top. a service is how containers behave in production. a stack defines all interactions of services.
Related:
- Dockerfile#(term Dockerfile)
- 1.
Text file containing all necessary instructions to assemble an image.
Related:
- image#(term image)
- 1.
A read-only template with instructions for creating a compute environment.
Related:
Multi-Stage Builds#
Use when you have multiple intermediate products generated in the course of your build. By using Docker’s multi-stage build capability you can simplify your Dockerfile(s), reduce disk usage, and improve performance through caching.
Each FROM statement starts a new stage of the build, which are referable by their index of appearance. Additionally, they may be named via the AS statement:
FROM ruby:2.6-alpine3.10 AS builder
Once referenced, any artifacts may be referenced or copied from other build stages:
COPY --from=builder /usr/app/_site /usr/share/nginx/html