Download - Dockerizing a Node.js Application - Give a sysadmin a fish for the day

Transcript

Justin Lovell | www.justjuzzy.com | @juzzy_za

Dockerizing a Node.js Application

Give a sysadmin a fish for the day

Justin Lovell | www.justjuzzy.com | @juzzy_za

JavaScript running as an Application Server?

T-t-t-that’s it. I’m burning this building down!

Justin Lovell | www.justjuzzy.com | @juzzy_za

Deployments and Infrastructure used to be simple

Justin Lovell | www.justjuzzy.com | @juzzy_za

Embrace change, but don’t screw it up

Developers must continuously implement change (responsibly)

System administrators need to keep systems operational

Very opposing goals

Justin Lovell | www.justjuzzy.com | @juzzy_za

Overwhelming for system administrators to learn to install, configure, and support

Justin Lovell | www.justjuzzy.com | @juzzy_za

Shipping Software is everybody’s Business

Justin Lovell | www.justjuzzy.com | @juzzy_za

Shipping Containers Changed the World 16 day travel time 750 kilometers a day 12,000 kilometers total Contents untouched

Docker Containers provides agility and promises of good

software shipment

Justin Lovell | www.justjuzzy.com | @juzzy_za

Operations Manage Infrastructure; not Software

192.168.0.1

192.168.0.1

192.168.0.1

192.168.0.1

192.168.0.1

192.168.0.1

192.168.0.1

Lorem

Lorm

Lorem

Lorem

Their goals: Big picture orientated Backups Disaster Recovery Networking

Software is a Junction Point Black box treatment Treatment is universal

The wish list Hardware appliances Virtual machine images

Justin Lovell | www.justjuzzy.com | @juzzy_za

Developers Pack Software Containers

Packaged by developers Simplified handling by operations No unintentional consequences

Justin Lovell | www.justjuzzy.com | @juzzy_za

Virtual Machines vs. Containers

Virtual Machines

Application

Software

Bins

Libs

Guest OS

Server Hardware

Host OS

Virtualized Hardware

Application

Software

Bins

Libs

Guest OS

Application

Software

Bins

Libs

Guest OS

Application

Software

Bins

Libs

Server Hardware

Host OS

Docker Deamon

Application

Software

Bins

Libs

Application

Software

Bins

Libs

Containers are isolated,but share OS kernel and, where appropriate, bins/libraries

…result is significantly faster deployment, much less overhead, easier migration, faster boot up times

Justin Lovell | www.justjuzzy.com | @juzzy_za

Containers Should Contain One Application

Place one app into one container

Containers are tools on the shadow board

The shadow should be instantly recognizable

Justin Lovell | www.justjuzzy.com | @juzzy_za

Demo 1: Isolation

$ docker search ubuntu

$ docker pull ubuntu

$ docker run -t -i ubuntu /bin/bash

$ e.g. top ifconf

$ exit

$ docker ps --all

Get Docker

http://docs.docker.com/mac/started/

http://docs.docker.com/linux/started/

http://docs.docker.com/windows/started/

Browse Docker Hub

https://registry.hub.docker.com/search?q=library

Execute Docker Image

Explore Container

Justin Lovell | www.justjuzzy.com | @juzzy_za

Demo 2: Sysadmin Install

$ docker pull ghost

$ docker run -d -p 80:2368 ghost

// todo: http://localhost/ghost

$ docker ps

$ docker stop <name>

Pull Ghost

Host Ghost

Visit Website

View running containers

Stop container

Justin Lovell | www.justjuzzy.com | @juzzy_za

Demo 3: Developer Package

$ git clone [email protected]:justin-lovell/jsinsa2015-docker.git

$ cd jsinsa2015-docker/node-app

$ vi Dockerfile

$ docker build -t <name/jsinsa> .

$ docker images

$ docker run -d -p 80:3000 <name/jsinsa>

$ docker run -d <name/jsinsa> test

$ docker stop $(docker ps -q)

$ docker build -t <name/jsinsa> .

Clone sample app

View Dockerfile

Build Dockerfile

View loaded images

Start Docker

Execute container variation

Stop all running containers

Rebuild image – Observe cache

Justin Lovell | www.justjuzzy.com | @juzzy_za

OPEN CONTAINER PROJECT

Open Collaborative Client Orchestration Stack

Not dominated by Commercial vendor Project

Portable across Operating systems Hardware CPU Architectures Public clouds

Justin Lovell | www.justjuzzy.com | @juzzy_za

Benefits for the System Administrator…

Capacity management orientated

Easily manage infrastructure

Accept changes more openly

Lightweight deployments

No developer jargon needed(e.g. npm)

192.168.0.1

192.168.0.1

192.168.0.1

192.168.0.1

192.168.0.1

192.168.0.1

192.168.0.1

Lorem

Lorm

Lorem

Lorem

Justin Lovell | www.justjuzzy.com | @juzzy_za

Reusability with pre-fabricated imagesPrimed for easier package management

Dependency management is a lot easierThe containers fully document all libraries, runtimes, and frameworks required

No more deployment documentationContainers has become the executable documentationDeployment documents will no longer become stale

Benefits for the Developer…

Containers has become the executable documentationDeployment documents will no longer become stale

Justin Lovell | www.justjuzzy.com | @juzzy_za

Learning Material

http://www.amazon.com/The-Docker-Book-Containerization-virtualization-ebook/dp/B00LRROTI4

http://www.dockerbook.com/

Justin Lovell | www.justjuzzy.com | @juzzy_za

Interesting Article

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

What is Docker and why is it so darn popular?

Docker, a new container technology, is hotter than hot because it makes it

possible to get far more apps running on the same old servers and it also

makes it very easy to package and ship programs. Here's what you need

to know about it.