@rob_rich
 
PPAI Tech Summit

 

 

 

Docker is more than Kernel Virtualization

by Rob Richardson

@rob_rich . https://robrich.org/

About Me

Rob Richardson is a software craftsman building web properties in ASP.NET and Node, React and Vue. He's a frequent speaker at conferences, user groups, and community events, and a diligent teacher and student of high quality software development. You can find this and other talks on https://robrich.org/presentations and follow him on twitter at @rob_rich.

DEMO:

Hello Docker

"Docker: VM++"

Docker is

  • ephemeral
  • isomorphic
  • deterministic


Therefore Docker is

ideal platform for dev & ops

  • clearly delineates duties
  • clean communication strategy

Docker is

  • ephemeral (short-lived)
  • isomorphic (unchanging)
  • deterministic (same every time)


Therefore Docker is

ideal platform for dev & ops

  • clearly delineates duties
  • clean communication strategy

What is Docker?

Docker is an ecosystem around Container Virtualization

What are Containers?

Light-weight kernel virtualization

What is Docker?

A suite of command-line tools for creating, running, and managing containers

Containers vs VMs

vm vs container

Source: http://www.zdnet.com/article/what-is-docker-and-why-is-it-so-darn-popular/

Containers

Containers virtualize and share the host kernel

Containers must run on the kernel for which they were built:

  • Linux containers run on a Linux host
  • Windows containers run on Windows Server host

Host Docker in a VM

docker nested in a vm

Docker Ecosystem

docker ecosystem

Download: https://robrich.org/slides/welcome-to-docker/docker-ecosystem.pdf

Installing Docker

Dockerfile

FROM node

WORKDIR /app

COPY package.json .
RUN npm install

COPY . .

ENV NODE_ENV production
ENV PORT 3000
EXPOSE 3000

CMD ["npm", "start"]

Layered Filesystem

Reading from the filesystem

Source: https://docs.docker.com/engine/userguide/storagedriver/aufs-driver/

Layered Filesystem

source

  • read/write layer
  • demo
    • CMD ["node" "server"]
    • EXPOSE 3000/tcp
    • server.js
    • WORKDIR /app
  • Node
    • Install Yarn
    • Install Node
    • Install gpg
    • node user/group
  • buildpack-deps:jessie
    • ... steps ...
  • parent image
    • ... steps ...
  • parent image
    • ... steps ...

Layered Filesystem

Only downloads each layer to disk once

because layers don't change

Volumes - non-temporary storage

Volume

Volumes are a pointer in the container
saved to a folder on the host

Volumes

In Dockerfile:

VOLUME ["/data"]

Starting container

docker run -v $(pwd):/data imagename
docker ecosystem

Download: https://robrich.org/slides/welcome-to-docker/docker-ecosystem.pdf

DEMO:

Craft Dockefile, build image, run container

docker ecosystem

Download: https://robrich.org/slides/welcome-to-docker/docker-ecosystem.pdf

docker ecosystem

Download: https://robrich.org/slides/welcome-to-docker/docker-ecosystem.pdf

docker-compose.yml - configuration as code

version: '3'
services:
  web:
    build: .
    ports:
    - "80:5000"
    volumes:
    - logvolume01:/var/log
    links:
    - redis
  redis:
    image: redis
volumes:
  logvolume01: {}

Source: https://docs.docker.com/compose/overview/

docker ecosystem

Download: https://robrich.org/slides/welcome-to-docker/docker-ecosystem.pdf

Docker Magic

Inside the Container:

  • A machine
  • Unique IP, hostname
  • Build your perfect snowflake
 

Outside the Container:

  • A process
  • Plug in power and internet
  • Restart quickly
  • Scale by launching more