Docker on Azure

May 2016 JaxARCSig

Docker

  • What are Containers?
  • New Docker Beta
  • Docker Commands

Docker Facts

  • Project started out dotCloud
  • Written in Go
  • Using Linux Isolation features of namespaces and cgroups 
  • Offer services like Docker Hub and Docker Cloud
  • Windows 2016 Server is adding Docker

Docker Beta

  • Uses hyper-V on Windows
  • Use xhyve on Mac OS X
  • Remove need for Oracle VirtualBox
  • Containers coming to Windows 2016

Docker terms

  • Docker Engine
  • Docker Machine
  • Docker Compose
  • Docker Swarm
  • Docker Hub
  • Docker Cloud

Common Docker Commands

  • docker build
  • docker run
  • docker run -i -t
  • docker run -d
  • docker attach
  • docker ps
  • docker ps -a
  • docker commit

Docker-Machine

  • docker-machine ls
  • docker-machine create
  • eval "$(docker-machine env default)"
  • docker-machine start
  • docker-machine stop
  • docker-machine kill

Docker Compose

  • Organize your containers and services
  • docker-compose.yml
  • 'docker-compose up' to deploy containers
  • Gives an abstraction for deploying multiple services

Docker Swarm

  • Combine a pool of Docker hosts into 1
  • Can create Clusters
  • Uses Docker API
  • Discovery Services
  • Scheduling

Docker Hub

  • A host for containers
  • Publish your containers
  • Search Public repositories
  • Pull down to build containers

Docker Cloud

  • Deploy to your own cloud
  • Define a node
  • Define cluster of nodes of same type
  • Cluster Nodes have to by of the same provider
  • You can use with AWS, Azure, Digital Ocean or your own hosts

Building Containers

  • Start with base image
  • Use Dockerfile to define and set up
  • Can run and commit, but better to use Dockerfile 
  • For Nodejs apps, split the npm install and adding code step into separate steps

Dockerfile

FROM node:6.2.0

RUN mkdir /src
COPY package.json /src
WORKDIR /src 
RUN npm install

ENV foo bar
 
# Add your source files
COPY . /src  
CMD ["npm","start"] 

Dockerfile commands

  • FROM specify base container image
  • ADD/COPY lets you add files to container
  • RUN will let you run a Bash command
  • CMD takes an array of commands
  • ENV sets up an environment variable
  • EXPOSE exposes a port
  • USER to set the user
  • WORKDIR to set the directory your working dir

Docker Build

bash > docker build -t username/container:version /src

Docker run

bash > docker run -d -p 80:3000 username/container:version

Provision Docker on Azure

bash > docker-machine create --driver azure --azure-subscription-id <subs-id> <machine-name>

Azure Docker tips

  • Use new management portal
  • Turn off when not using
  • Delete storage when not used
  • Add ports to firewall that you need
  • --azure-open-port

Honorable Mentions

  • Kubernetes
  • Mesos
  • Heroku

Demo

Code

  • https://github.com/jaxnode-UG/jaxnodechat
  • https://slides.com/davidfekke/dockerazure

Questions

Contact

  • David Fekke @ gmail dot com
  • Twitter @JaxNode
  • Skype: davidfekke

Deploying Docker to Azure

By David Fekke

Deploying Docker to Azure

These are the slides for the May 2016 JaxARCSig meetup. This presentation will cover deploying applications with Docker to Azure.

  • 1,614