@rob_rich

Welcome to Docker

by Rob Richardson

@rob_rich

https://robrich.org/

About Me

Rob Richardson is a software craftsman building web properties in ASP.NET and Node, Angular and React. 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 his blog at https://robrich.org/presentations and follow him on twitter at @rob_rich.

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 Server Core
  • Windows Nano Server

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

Docker Machine Drivers

Control a different hypervisor

docker-machine -d thedriver ...

  • Amazon Web Services
  • Microsoft Azure
  • Digital Ocean
  • Exoscale
  • Google Compute Engine
  • Generic
  • Microsoft Hyper-V
  • OpenStack
  • Rackspace
  • IBM Softlayer
  • Oracle VirtualBox
  • VMware vCloud Air
  • VMware Fusion
  • VMware vSphere

Source: docs.docker.com/machine/drivers

Dockerfile - configuration as code

FROM ubuntu:14.04

RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
RUN apt-get update
RUN apt-get install -y nodejs

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app

EXPOSE 5000
CMD [ "npm", "start" ]

Dockerfile - configuration as code

This is broken, see building node nanoserver image

FROM microsoft/windowsservercore

ENV NODE_VERSION 6.2.0
RUN powershell -Command \
    wget -Uri https://nodejs.org/dist/v%NODE_VERSION%/node-v%NODE_VERSION%-x64.msi -OutFile node.msi -UseBasicParsing ; \
    Start-Process -FilePath msiexec -ArgumentList /q, /i, node.msi -Wait ; \
    Remove-Item -Path node.msi

RUN mkdir -p \app
WORKDIR /app

COPY package.json /app
RUN npm install
COPY . /app

EXPOSE 5000
CMD [ "npm", "start" ]
docker ecosystem

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

Layered Filesystem

Docker layered filesystem

Source: http://www.slideshare.net/vitalytsaplin/docker-59698147

Dockerfile - configuration as code

FROM ubuntu:14.04

# RUN apt-get update
# RUN apt-get install -y nodejs npm
RUN apt-get update && apt-get install -y nodejs npm

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app

EXPOSE 5000
CMD [ "npm", "start" ]

Layered Filesystem

Reading from the filesystem

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

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

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

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