docker training course - discuss docker, chef, puppet, ansible, salt stack hangout
DESCRIPTION
Discuss docker, chef, puppet, ansible, salt stack Hangout on March 18, 2014. Basic Docker concepts, commands, trivia, cool tricksTRANSCRIPT
Docker Training
Discuss Docker, Chef, Puppet, Ansible, SaltStack
March 18, 2014
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
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
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.
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
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
Docker labs
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
docker pull ubuntu: precise
docker pull ubuntu:12.04Command:
Pull Ubuntu 12.04 LTS Precise Base
ImagePurpose:
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
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
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
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
docker diff
docker diff CONTAINERCommand:
List the changes in files and directories in a container’s filesystem
Purpose:
Docker Dev Workflow
Applications
VyScale -- python flask + MySQL
flux7.com -- php +MySQL
client1 -- python + Cassandra (multi-tenant)
client2 -- Ruby on Rails + MySQL + Redis
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
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
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
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
QA
Jenkins polls the repo for pushes
Uses the same script to run the tests using containers
Code delivery
Existing containers are destroyed (can be better)
New containers are built and started
Chef recipe update
devenv rebuilddevenv push
Behind the scenes:
1. create new containers by running chef recipes
2. commit contains to the master registry
Add/remove a service/tier
Change devenv script
Questions?