getting started with docker

Post on 13-Feb-2017

56 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

DockerAn Introduction & Getting Started

Agenda

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

What’s the Big Deal?

LAMP

Once upon a time…

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

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

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ?

Standardized Container

Separation of Concerns

Docker ContainerStatic website Web frontend User 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 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

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 isolation

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

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

DEMO

Hello World

$ docker run hello-world

Whalesay

$ docker run docker/whalesay cowsay foobar

Whalesay: DockerfileFROM docker/whalesay:latestRUN apt-get -y update && apt-get install –y fortunesCMD /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

top related