You are on page 1of 21

Getting started with Docker

February 5, 2015
David Carew
IT Architect
Ecosystem Development

© 2014 IBM Corporation


Agenda
Docker Overview
Bluemix Container service
Demo
Resources

2
#Bluemix
The Challenge

3
#Bluemix
The Matrix From Hell

4
#Bluemix
Cargo Transport Pre-1960

5
#Bluemix
Solution: Intermodal Shipping Container

6
#Bluemix
Docker is a shipping container system for code

7
#Bluemix
Docker eliminates the matrix from Hell

8
#Bluemix
Why it works –separation of concerns

9
#Bluemix
Containers vs VMs

10
#Bluemix
More on Containers
 A Docker container consists of an operating system,
user-added files, and meta-data – Basically a way to
run mini operatingsystems in your host operating
system with strong guarantees of isolation !

 The Docker image is read-only. When Docker runs a


container from an image, it adds a read-write layer on
top of the image (using a union file system) in which
your application can then run

 Underlying Technology : Written in Go and makes use


of several
 Linux kernel features
 Namespaces - pid, net, mnt, ipc, etc.!
 Control Groups - cgroups (memory, cpu, blkio,
devices)!Union File Systems - UnionFS (AUFS,
btrfs, vfs)!
 Container Format - libcontainer or LXC

11
#Bluemix
Why are Docker containers lightweight ?

12
#Bluemix
What are the basics of a Docker system ?

13
#Bluemix
Changes and Updates

14
#Bluemix
Client Server Architecture on different platforms
Native Linux (eg Ubuntu) Windows via boot2docker* Mac via boot2docker Windows/Mac via VM

Linux OS Windows OS Mac OSX Native OS

docker-client VirtualBox VM docker-client VirtualBox/VMWare


Tiny Core Linux Ubuntu VM

docker-client docker-client

docker-daemon VirtualBox VM
Tiny Core Linux

docker-daemon docker-daemon
docker-daemon
containers
containers
containers containers

15
#Bluemix
Docker Images, Dockerfile and Docker Registry
 Docker images are read-only templates from which
Docker containers are launched.

 Each image consists of a series of layers. Docker


makes use of union file systems to combine these
layers into a single image – that’s why Docker is so
lightweight .

 Every image starts from a base image, for example


ubuntu, a base Ubuntu image, or fedora, a base
Fedora image. Docker images are then built from
these base images using a simple, descriptive set of
steps we call instructions.

 These instructions are stored in a file called a


Dockerfile. Docker reads this Dockerfile when you
request a build of an image, executes the
instructions, and returns a final image.

 Docker images are hosted on Docker hub or registry

16
#Bluemix
Bluemix Container Service
Currently Experimental
Docker environment for running Docker containers
• Tenant private registry + read only public registry
– Currently 2 public images
• Node.js and WAS Liberty
• Both on an Ubuntu 14.04 base
• Containers can access Bluemix Services
– Can inject service metadata into Container’s ENV
• Command extensions provided for Bluemix specific tasks (e.g. bind a container to an
app’s services)
– Command extensions not supported on boot2docker on Windows
• Use Linux VM instead
• Provides public IPs that can be mapped to specific containers
– Only ports 22, 80, 443, 9080, and 9443 can be accessed

17
#Bluemix
Demo
Running Shiny+RHRV on Bluemix via a Docker container
• BD&A Days demo has a Bluetooth heart monitor than transmits ECG data into the
DashDB service in Bluemix
– R packages, RHRV and Shiny allow analytics and visualization of that data
• Current Bluemix/Cloud Foundry Warden containers don’t support RHRV and Shiny
» A very complex setup requiring a lot of dependencies
• Using Bluemix Container service we are building a Docker image to run Shiny+RHRV and point to the
DashDB data
» Shows the value of Docker – very complex setup reduced to a single Dockerfile

18
#Bluemix
Dockerfile for Shiny+RHRV Part 1
FROM ubuntu:14.04

MAINTAINER David Carew <carew@us.ibm.com>

# Install Oracle Java 7 SDK


RUN \

# Install R
RUN \

# Define working directory
WORKDIR /data

# Define commonly used JAVA_HOME variable


ENV JAVA_HOME /usr/lib/jvm/java-7-oracle

# SSH
RUN apt-get update && apt-get install -y openssh-server && mkdir -p /var/run/sshd
COPY authorized_keys /root/.ssh/

# Supervisor config file


RUN apt-get update && apt-get install -y supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# Install Ubuntu packages required for our use of Shiny


RUN \

# Install shiny R package and the other R packages requred for our use of Shiny

19
#Bluemix
Dockerfile for Shiny+RHRV Part 2
# Install shiny server
RUN

# Change port from default 3838 to 80


RUN \

# Copy Shiny app into container


ADD insight2014-shiny /srv/shiny-server/insight2014-shiny

# Ports used
EXPOSE 22 80

# Define default command.


CMD ["/usr/bin/supervisord"]

20
#Bluemix
Resources
IBM Bluemix Container Service video
• https://www.youtube.com/watch?v=-fcMeHdjC2g
IBM Bluemix Container docs
• https://www.ng.bluemix.net/docs/#services/Containers/index.html

Docker documentation
• https://docs.docker.com/

Feel free to contact me if you have any questions

21
#Bluemix

You might also like