Introduction to docker

1,840 views
1,510 views

Published on

A brief introduction to docker.

Demo:
Run Bottle, a simple python web framework, in a docker container

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,840
On SlideShare
0
From Embeds
0
Number of Embeds
30
Actions
Shares
0
Downloads
59
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Introduction to docker

  1. 1. Introduction to Docker Willy Kuo Feb 25, 2013
  2. 2. About Me • About me • Work at numerinfo.com • Organizor of 
 http://www.meetup.com/Docker-Taipei/ • https://github.com/waitingkuo • waitinguo0527@gmail.com
  3. 3. The Challenge
  4. 4. The Matrix From Hell
  5. 5. Cargo Transport Pre-1960
  6. 6. The Matrix From Hell
  7. 7. Solution: 
 Intermodal Shipping Container
  8. 8. Docker is a shipping container system for code
  9. 9. Docker eliminates the matrix from hell
  10. 10. Deploy to almost anywhere OK Soon Soon ?
  11. 11. VMs vs Containers
  12. 12. VMs vs Containers
  13. 13. Installation • Natively (Linux)
 http://docs.docker.io/en/latest/installation/ #installation-list • Boot2Docker (Linux, OSX)
 https://github.com/boot2docker/boot2docker • Vagrant 
 https://github.com/waitingkuo/docker-vagrant
  14. 14. Play Docker via Vagrant • Install vagrant & virtualbox • $ git clone https://github.com/waitingkuo/dockervagrant.git
 $ cd docker-vagrant
 $ vagrant up
 $ vagrant ssh • Start to play docker
  15. 15. Download a pre-built image • $ docker pull ubuntu • You can find more images here
 https://index.docker.io/
  16. 16. Docker Images? • $ docker images
  17. 17. Run Something… • $ docker run ubuntu echo hi • $ docker run ubuntu uname -a • $ docker run ubuntu ifconfig
  18. 18. How about running bash? • $ docker run ubuntu bash • oops • $ docker run -i -t ubuntu bash
  19. 19. Let’s install something • $ docker run ubuntu apt-get install -y python-pip • Try to install something via pip • $ docker run ubuntu pip install bottle • Where’s my pip?
  20. 20. docker ps • $ docker ps • Nothing … • $ docker -a • Too much … • $ docker ps -l • That’s it
  21. 21. Think about Git • Coding… • $ git add -A • $ git commit -m ‘xxx’
  22. 22. Commit!!? • $ docker commit <container-id> mypip • Now, you have a new image called mypip • $ docker images
  23. 23. Finally, you can use pip • $ docker run mypip pip install bottle • $ docker commit <container-id> mybottle
  24. 24. Time to run a web server • Run a simple website using bottle framework • https://github.com/waitingkuo/bottle-sample
  25. 25. Clone our project! • First, we need git • $ docker run mybottle apt-get install git-core • uuuh… Seems we need to do apt-get update
  26. 26. Apt-get update and install again • $ docker run mybottle apt-get update • $ docker commit <container-id> myupdate • $ docker run myupdate apt-get install git-core • $ docker commit <container-id> mygit

  27. 27. Clone our project part 2 • $ docker run mygit git clone https://github.com/ waitingkuo/bottle-sample.git • docker commit <container-id> myweb
  28. 28. Bottle Rock • $ docker run myweb python bottle-sample/app.py • htttp://192.168.66.66:8080
 (192.168.66.66 is the ip for the virtual machine we create by vagrant) • What the fuckrock??
  29. 29. Port forwarding • $ docker run -p 9999:8080 myweb python bottlesample/app.py
  30. 30. Daemonize? • $ docker run -p 9999:8080 myweb python bottlesample/app.py • Now, our web server is running in the background • $ docker ps
  31. 31. Can we kill it? • just like the kill command, except that we should assign the container id instead of pid • $ docker kill <container-id>
  32. 32. Dockerfile • Tutorial: https://www.docker.io/learn/dockerfile/
  33. 33. Example Dockerfile
 • 
 FROM ubuntu 
 
 RUN apt-get update 
 RUN apt-get install -y git-core 
 
 RUN apt-get install -y python-pip 
 RUN pip install bottle 
 
 RUN git clone https://github.com/waitingkuo/bottle-sample.git 
 
 CMD python bottle-sample/app.py
  34. 34. Build image by Dockerfile • $ docker built -t myweb-2 . # don’t forget the . • Now, you have a new image, myweb-2 • $ docker image • $ docker run -p 9999:8080 myweb-2 python bottlesample/app.py
  35. 35. Think about GitHub • We have already had docker commit • Can I push my image to something like GitHub?
  36. 36. Docker Index • https://index.docker.io/ • The place to find Docker container images • Can automatically create Docker Image from your project on Github, and keep them in sync
  37. 37. The basics of the 
 Docker System
  38. 38. Changes & Updates
  39. 39. Example Deploy Mongodb • https://index.docker.io/u/waitingkuo/mongodb/ • The Dockfile is hosted on Github
 https://github.com/waitingkuo/dockerfiles/blob/ master/dockerfiles/mongodb/Dockerfile • $ docker run -d -p 27017:27017 -p 28017:28017 waitingkuo/mongodb • Mongodb is running
 http://192.168.66.66:28017/
  40. 40. Ecosystem - WebUI • dockerui
 https://github.com/crosbymichael/dockerui • Shipyard
 https://github.com/shipyard/shipyard
  41. 41. Ecosystem - PaaS • deis
 https://github.com/opdemand/deis • dokku
 https://github.com/progrium/dokku • flynn
 https://flynn.io/
  42. 42. Ecosystem - CI • drone
 https://github.com/drone/drone • StriderCD
 http://stridercd.com/
  43. 43. Thank you!

×