Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

25
Docker Training Discuss Docker, Chef, Puppet, Ansible, SaltStack March 18, 2014

description

Discuss docker, chef, puppet, ansible, salt stack Hangout on March 18, 2014. Basic Docker concepts, commands, trivia, cool tricks

Transcript of Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Page 1: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Docker Training

Discuss Docker, Chef, Puppet, Ansible, SaltStack

March 18, 2014

Page 2: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

WHO AM I?

Aater Suleman

Geek, Architect, Developer, Ops, DevOps …

Co-founder & CEO Flux7 Labs

Part-time UT Austin Professor

Flux7 Labs: AWS and DevOps Solutions

■ Web

■ Big data

■ HPC

in/aatersuleman

@FutureChips

Flux7Labs

@Flux7Labs

www.flux7.com

Page 3: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Basic concepts

Docker - Not a replacement to LXC

Namespaces:

● First level of isolation

● Process running in a container cannot see or affect other

processes running outside the container

Control Groups:

● Key Component of LXC

● Resource Accounting and Limiting are the key functions.

● Significant to multi-tenant platforms: Guarantees consistent

uptime and performance

Page 4: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

LXCs

LXCs are lightweight .

Run multiple isolated instances on the same host

Share a single kernel, but can have a set definition for the number of resources they can consume.

Does not allow interference among instances.

Page 5: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Docker Terminology

Docker Registry: is a registry server for Docker that helps hosting and delivery of repositories and images

Layer: Each file system that is stacked when Docker mounts rootfs

Image: is a read-only layer that never changes

Container: Self-contained environment built using one or more images. Images can be created based on the committed containers

Repository: Set of images on local Docker or Registry server

Page 6: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Docker Files

Dockerfiles allow describing build steps once and later build a

container automatically from source

Can be viewed as an image representation

Helps

● Build images easily

● Automates and scripts image creation

Page 7: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Docker labs

Page 8: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Install Docker (Ubuntu 13.10)

Add Docker repository to local keychain:sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys

36A1D7869245C8950F966E92D8576A8BA88D21E9

Add Docker repo to apt source list, update and install lcx-docker packagesudo sh -c "echo deb http://get.docker.io/ubuntu docker main\

> /etc/apt/sources.list.d/docker.list"

sudo apt-get update

sudo apt-get install lxc-docker

Verify Installationsudo docker run -i -t ubuntu /bin/bash

Page 9: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

docker pull ubuntu: precise

docker pull ubuntu:12.04Command:

Pull Ubuntu 12.04 LTS Precise Base

ImagePurpose:

Page 10: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

docker run

Choose a mode to run the Docker container

run background/

detached run

run foreground

run interactive

1. Container does not listen

2. IO is done through Network or sharing

1. Default Mode

2. Attaches console to the process’s stdin, stdout, stderr

1. Persistent standard input needed

Page 11: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

docker run ssh

# sshd## VERSION 0.0.1

FROM ubuntuMAINTAINER Thatcher R. Peskens "[email protected]"

# make sure the package repository is up to dateRUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.listRUN apt-get update

RUN apt-get install -y openssh-serverRUN mkdir /var/run/sshd RUN echo 'root:screencast' |chpasswd

EXPOSE 22CMD /usr/sbin/sshd -D

Dockerfile to set up an sshd service in a container

Page 12: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

docker run (port forwarding)

docker run -P <imageid>Command:

docker run -p [([<host_interface>:[host_port]])|(<host_port>):]<container_port>[/udp] <image> <cmd>

Command:

Auto-map all exposed ports to host:

Binding a port to a host interface

Page 13: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

docker run (volume sharing)

Command: docker run -v /var/volume1 -v /var/volume2 DATA busybox true

Create container with 2 volumes

Mount Data volumes into application container

Command: docker run -t -i -rm -volumes-from DATA -name client1 ubuntu bash

Page 14: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

docker diff

docker diff CONTAINERCommand:

List the changes in files and directories in a container’s filesystem

Purpose:

Page 15: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Docker Dev Workflow

Page 16: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Applications

VyScale -- python flask + MySQL

flux7.com -- php +MySQL

client1 -- python + Cassandra (multi-tenant)

client2 -- Ruby on Rails + MySQL + Redis

Page 17: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Web App

DB

LogStashMem$

HTTP

SSH

Vbox

App Code

Laptop

Scripts for convenience

Docker Registry in

AWS or Docker.com

Dev edits code in their favorite editor

Page 18: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

New Hire/New laptop

Install Vagrant

git pull <code repository>

devenv setup

devenv start

Behind the scenes:

1. Download the Vbox image2. Run VM to share a folder + expose the ports + static IP 3. Build containers4. Start containers in the right order and exposing the right ports (DB ??)5. Copy log volumes in the /vagrant/log folder6. Setup /etc/hosts to point to the VM7. Print URL to access the application

Page 19: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Debug flow

Edit code (in the editor of your choice, be able to use all your aliases and commands)

// Restart the server (can be automated using unicorn)devenv load

// check the logs in top/logs folder

Page 20: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Code commit

devenv commit -t <tag> ← for debugging later

git push

Behind the scenes:

1. Commit all docker containers

2. Save versions for future use

Page 21: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

QA

Jenkins polls the repo for pushes

Uses the same script to run the tests using containers

Page 22: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Code delivery

Existing containers are destroyed (can be better)

New containers are built and started

Page 23: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Chef recipe update

devenv rebuilddevenv push

Behind the scenes:

1. create new containers by running chef recipes

2. commit contains to the master registry

Page 24: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Add/remove a service/tier

Change devenv script

Page 25: Docker training course - Discuss docker, chef, puppet, ansible, salt stack Hangout

Questions?