Suggested Topics
• Composer
• Vagrant
• Kafka
• React / React
Native / Flow
• More Docker
• General JavaScript
• Organization
principals
• Node JS / Node
promises
• GIS
• SQL
Topics
• CoffeeScript
• Unit Testing
• Polyfills
• Interaction Design / Improving User
Experience
• Mobile testing
• A/B Testing
• Regression testing
• Performance optimization
• Dev tools
• D3.js / three.js / processing's / etc
• Source Maps
• Static site generators
• Accessibility for Rich Internet
applications (ARIA)
• GeoJSON and mapping API’s
• Electron
• Node.js
• Kalabox
• Server Security
• GreenSocks Animations
• Google Analytics
• Test Driven Development
• Command Line
Mark Aplet
@visual28
Web Developer at Symsoft
Docker
An Introduction & Getting Started
Agenda
• Background
• Installation
• Commands
• Hello World
• Dockerfile
• Docker Compose
What’s the Big Deal?
LAMP
Once upon a time…
The Challenge Today
Static website
nginx 1.5 + modsecurity + openssl + bootstrap
User DB
postgresql + pgv8 + v8
Analytics DB
hadoop + hive + thrift + OpenJDK
Web frontend
Ruby + Rails + sass + Unicorn
Queue
Redis + redis-sentinel
Background workers
Python 3.0 + celery + pyredis + libcurl + ffmpeg +
libopencv + nodejs + phantomjs
API endpoint
Python 2.7 + Flask + pyredis + celery +
psycopg + postgresql-client
Development VM
QA server
Disaster recovery
Contributor’s laptop
Production Servers
Production Cluster
Customer Data Center
Matrix From Hell
Static website
Web frontend
Background workers
User DB
Analytics DB
Queue
Development VM QA Server Single Prod Server Onsite Cluster Public Cloud
Contributor’s
laptop
Customer Servers
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Standardized Container
Separation of Concerns
Docker Container
Static website Web frontendUser DB Queue Analytics DB
Development
VM
QA server
Public Cloud
Contributor’s
laptop
Production
Cluster
Customer
Data Center
Virtualization
Virtual
Machines
• Hardware VM’s been
around a long time
• Allows multiple guest
systems to live on a
single host
• Snapshots “freeze”
state at that point
• Can be migrated
from one host to
another
VM
Problems
• Ship too many bits
• Each VM contained
independent OS and
resource pool
• Scale may not be of
value
Innovation
• Created opportunity to
cut out unnecessary
features to create
lightweight process
virtualization
• lead to creation of
LXC containers. (Linux
Containers)
• Much smaller OS with
minimal resource
requirements that
boots in seconds
VM vs Container
Hypervisor (Type 2)
Host OS
Server
Guest
OS
Bins/Lib
s
Docker
VM
Container
App 1
Guest
OS
Bins/Lib
s
App 1
Guest
OS
Bins/Lib
s
App 2
Host OS
Server
App1
App1
App1
App2
App2
App2
App2
Bins/Libs Bins/Libs
Enter
Docker
• Removing of the
unnecessary parts of
OS continued
• 2013 DotCloud (now
Docker) really
pushed the
boundaries of
lightweight process
virtualization
Enter
Docker
• A Docker container
unlike VM's or LXC
does not require or
include a separate
OS
• Docker instead relies
on the Linux kernel
functionality and
uses resource
Get Started
Download
• docker.com
• Docker for Mac/Win
for newer systems
• Docker toolbox for
older systems
Helpful
• Prior knowledge of
Linux is helpful
• Use Docker CLI in
terminal
Commands
COMMANDS
ps = Process
images = images on
host
run = run a command
rm = Remove Process
rmi = remove image
FLAGS
-a = All Hidden
-d = detached mode
-ti = Terminal
Interactive
-p = Port number
-v = Volume
DEMO
Hello World
$ docker run hello-world
Whalesay
$ docker run docker/whalesay cowsay foobar
Whalesay: Dockerfile
FROM docker/whalesay:latest
RUN apt-get -y update && apt-get install –y fortunes
CMD /usr/games/fortune -a | cowsay
$ docker build -t docker-whale .
MySQL
$ docker pull mysql
$ docker run --name wordpressdb
-e MYSQL_ROOT_PASSWORD=password
-e MYSQL_DATABASE=wordpress -d mysql:5.7
WordPress
$ docker pull wordpress
$ docker run
-e WORDPRESS_DB_PASSWORD=password
--name mywordpress
--link wordpressdb:mysql
-p 8080:80 -d
-v "$PWD/":/var/www/html wordpress
WordPress: Docker-Compose
version: '2'
services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
links:
- db
ports:
- "8080:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: wordpress
volumes:
- ./wp-content/:/var/www/html/wp-content

Getting Started with Docker

  • 2.
    Suggested Topics • Composer •Vagrant • Kafka • React / React Native / Flow • More Docker • General JavaScript • Organization principals • Node JS / Node promises • GIS • SQL
  • 3.
    Topics • CoffeeScript • UnitTesting • Polyfills • Interaction Design / Improving User Experience • Mobile testing • A/B Testing • Regression testing • Performance optimization • Dev tools • D3.js / three.js / processing's / etc • Source Maps • Static site generators • Accessibility for Rich Internet applications (ARIA) • GeoJSON and mapping API’s • Electron • Node.js • Kalabox • Server Security • GreenSocks Animations • Google Analytics • Test Driven Development • Command Line
  • 4.
  • 5.
    Docker An Introduction &Getting Started
  • 6.
    Agenda • Background • Installation •Commands • Hello World • Dockerfile • Docker Compose
  • 7.
  • 8.
  • 9.
    The Challenge Today Staticwebsite nginx 1.5 + modsecurity + openssl + bootstrap User DB postgresql + pgv8 + v8 Analytics DB hadoop + hive + thrift + OpenJDK Web frontend Ruby + Rails + sass + Unicorn Queue Redis + redis-sentinel Background workers Python 3.0 + celery + pyredis + libcurl + ffmpeg + libopencv + nodejs + phantomjs API endpoint Python 2.7 + Flask + pyredis + celery + psycopg + postgresql-client Development VM QA server Disaster recovery Contributor’s laptop Production Servers Production Cluster Customer Data Center
  • 10.
    Matrix From Hell Staticwebsite Web frontend Background workers User DB Analytics DB Queue Development VM QA Server Single Prod Server Onsite Cluster Public Cloud Contributor’s laptop Customer Servers ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
  • 12.
    ? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
  • 13.
  • 14.
  • 15.
    Docker Container Static websiteWeb frontendUser DB Queue Analytics DB Development VM QA server Public Cloud Contributor’s laptop Production Cluster Customer Data Center
  • 16.
  • 17.
    Virtual Machines • Hardware VM’sbeen around a long time • Allows multiple guest systems to live on a single host • Snapshots “freeze” state at that point • Can be migrated from one host to another
  • 18.
    VM Problems • Ship toomany bits • Each VM contained independent OS and resource pool • Scale may not be of value
  • 19.
    Innovation • Created opportunityto cut out unnecessary features to create lightweight process virtualization • lead to creation of LXC containers. (Linux Containers) • Much smaller OS with minimal resource requirements that boots in seconds
  • 21.
    VM vs Container Hypervisor(Type 2) Host OS Server Guest OS Bins/Lib s Docker VM Container App 1 Guest OS Bins/Lib s App 1 Guest OS Bins/Lib s App 2 Host OS Server App1 App1 App1 App2 App2 App2 App2 Bins/Libs Bins/Libs
  • 22.
    Enter Docker • Removing ofthe unnecessary parts of OS continued • 2013 DotCloud (now Docker) really pushed the boundaries of lightweight process virtualization
  • 23.
    Enter Docker • A Dockercontainer unlike VM's or LXC does not require or include a separate OS • Docker instead relies on the Linux kernel functionality and uses resource
  • 24.
  • 25.
    Download • docker.com • Dockerfor Mac/Win for newer systems • Docker toolbox for older systems
  • 26.
    Helpful • Prior knowledgeof Linux is helpful • Use Docker CLI in terminal
  • 27.
    Commands COMMANDS ps = Process images= images on host run = run a command rm = Remove Process rmi = remove image FLAGS -a = All Hidden -d = detached mode -ti = Terminal Interactive -p = Port number -v = Volume
  • 28.
  • 29.
    Hello World $ dockerrun hello-world
  • 30.
    Whalesay $ docker rundocker/whalesay cowsay foobar
  • 31.
    Whalesay: Dockerfile FROM docker/whalesay:latest RUNapt-get -y update && apt-get install –y fortunes CMD /usr/games/fortune -a | cowsay $ docker build -t docker-whale .
  • 32.
    MySQL $ docker pullmysql $ docker run --name wordpressdb -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress -d mysql:5.7
  • 33.
    WordPress $ docker pullwordpress $ docker run -e WORDPRESS_DB_PASSWORD=password --name mywordpress --link wordpressdb:mysql -p 8080:80 -d -v "$PWD/":/var/www/html wordpress
  • 34.
    WordPress: Docker-Compose version: '2' services: db: image:mysql:5.7 volumes: - "./.data/db:/var/lib/mysql" restart: always environment: MYSQL_ROOT_PASSWORD: wordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest links: - db ports: - "8080:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_PASSWORD: wordpress volumes: - ./wp-content/:/var/www/html/wp-content

Editor's Notes

  • #15 * Takes more effort to deploy software than to ship physical goods
  • #16 * Developers create a box that they fill with data, * Infrastructure worries about how to deploy the box
  • #22 • Containers are isolated, but share OS and, where appropriate, bins/libraries