A thirty minutes intro to docker

Wikimedia Foundation, 2021

Prerequisites

Wikimedia Foundation, 2021

Follow along

A copy of these slides, and supporting code can be found
here and here.

Quickstart:

git clone git@github.com:gmodena/wmf-docker-thirty-minutes.git
Wikimedia Foundation, 2021

What's a docker?

A CLI to Linux capabilities and interfaces that we use to build, start and stop application containers.
w:320 h:295
User:Maklaan, Public domain, via Wikimedia Commons

Wikimedia Foundation, 2021

Use cases

  • Packaging and vendoring of complex dependencies.
  • Developer productivity.
  • Lightweight "virtualisation".
  • Running unit tests and CI pipelines.
Wikimedia Foundation, 2021

Images, containers

  • An image is a read-only file that contains all dependencies that an application needs to run (e.g. glibc, python, flask, nginx, bash).
  • A container is a run-time environment (atop Linux capabilities) on which applications (and their deps) run isolated from the host OS while sharing the same kernel.
  • Docker Hub is an online repository of images, that can be fetched to run containers.
Wikimedia Foundation, 2021

Hello world

docker run hello-world

What did just happen?
Explore a Unix inspired cli: docker ps|cp|kill|help.

Wikimedia Foundation, 2021

Writing our own image

Before we pulled an existing image. Now we'll write on from scratch.

  • We first need to define a Dockerfile with the required deps. It contains instructions to build Docker images.
  • We then build an image with docker build -t hello-pythonic-world .
  • And finally run a container with docker run hello-pythonic-world.
Wikimedia Foundation, 2021

Blubber: high level Dockerfile descriptions

Wikimedia Foundation, 2021

Blubber: hello-blubber.yaml

version: v4
base: docker-registry.wikimedia.org/wikimedia-stretch

variants:
  hello:
    entrypoint: [echo, "Hello, world!"]
Wikimedia Foundation, 2021

Blubber: build & run

  • blubber hello-blubber.yaml hello > Dockerfile
  • cat Dockerfile
  • docker build --tag blubber-tutorial-hello-world .
  • docker run blubber-tutorial-hello-world:latest
Wikimedia Foundation, 2021

Where to go next

  • managing volumes and networks.
  • security of docker containers.
  • docker-compose.
  • kubernetes.
Wikimedia Foundation, 2021