getting started with docker

34

Upload: visual28

Post on 13-Feb-2017

56 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Getting Started with Docker
Page 2: Getting Started with Docker

Suggested Topics• Composer• Vagrant• Kafka • React / React

Native / Flow• More Docker

• General JavaScript• Organization principals• Node JS / Node

promises • GIS• SQL

Page 3: Getting Started with Docker

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

Page 4: Getting Started with Docker

Mark Aplet@visual28

Web Developer at Symsoft

Page 5: Getting Started with Docker

DockerAn Introduction & Getting Started

Page 6: Getting Started with Docker

Agenda

• Background• Installation• Commands• Hello World• Dockerfile• Docker Compose

Page 7: Getting Started with Docker

What’s the Big Deal?

Page 8: Getting Started with Docker

LAMP

Once upon a time…

Page 9: Getting Started with Docker

The Challenge TodayStatic website

nginx 1.5 + modsecurity + openssl + bootstrap

User DBpostgresql + pgv8 + v8

Analytics DBhadoop + hive + thrift + OpenJDK

Web frontend Ruby + Rails + sass + Unicorn

QueueRedis + redis-

sentinel

Background workersPython 3.0 + celery + pyredis + libcurl +

ffmpeg + libopencv + nodejs + phantomjs

API endpointPython 2.7 + Flask + pyredis + celery + psycopg + postgresql-

client

Development VM

QA serverDisaster recovery

Contributor’s laptopProduction Servers

Production Cluster

Customer Data Center

Page 10: Getting Started with Docker

Matrix From HellStatic 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

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

Page 11: Getting Started with Docker
Page 12: Getting Started with Docker

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

Page 13: Getting Started with Docker

Standardized Container

Page 14: Getting Started with Docker

Separation of Concerns

Page 15: Getting Started with Docker

Docker ContainerStatic website Web frontend User DB Queue Analytics DB

Development VM

QA server Public Cloud

Contributor’s laptop

Production Cluster

Customer Data Center

Page 16: Getting Started with Docker

Virtualization

Page 17: Getting Started with Docker

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

Page 18: Getting Started with Docker

VM Problems

• Ship too many bits• Each VM contained

independent OS and resource pool

• Scale may not be of value

Page 19: Getting Started with Docker

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

Page 20: Getting Started with Docker
Page 21: Getting Started with Docker

VM vs Container

Hypervisor (Type 2)Host OSServer

GuestOS

Bins/Libs

Docker

VMContainer

App 1

GuestOS

Bins/Libs

App 1

GuestOS

Bins/Libs

App 2

Host OSServer

App 1

App 1

App 1

App 2

App 2

App 2

App 2

Bins/Libs Bins/Libs

Page 22: Getting Started with Docker

Enter Docker

• Removing of the unnecessary parts of OS continued

• 2013 DotCloud (now Docker) really pushed the boundaries of lightweight process virtualization

Page 23: Getting Started with Docker

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 isolation

Page 24: Getting Started with Docker

Get Started

Page 25: Getting Started with Docker

Download

• docker.com

• Docker for Mac/Win for newer systems

• Docker toolbox for older systems

Page 26: Getting Started with Docker

Helpful

• Prior knowledge of Linux is helpful

• Use Docker CLI in terminal

Page 27: Getting Started with Docker

CommandsCOMMANDSps = Processimages = images on hostrun = run a commandrm = Remove Processrmi = remove image

FLAGS-a = All Hidden-d = detached mode-ti = Terminal Interactive-p = Port number-v = Volume

Page 28: Getting Started with Docker

DEMO

Page 29: Getting Started with Docker

Hello World

$ docker run hello-world

Page 30: Getting Started with Docker

Whalesay

$ docker run docker/whalesay cowsay foobar

Page 31: Getting Started with Docker

Whalesay: DockerfileFROM docker/whalesay:latestRUN apt-get -y update && apt-get install –y fortunesCMD /usr/games/fortune -a | cowsay

$ docker build -t docker-whale .

Page 32: Getting Started with Docker

MySQL$ docker pull mysql

$ docker run --name wordpressdb -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress -d mysql:5.7

Page 33: Getting Started with Docker

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

Page 34: Getting Started with Docker

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