Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mini training - Containerization and Docker

Mini training - Containerization and Docker

Betclic mini-training:

Mickael Metesreau

March 06, 2015
Tweet

More Decks by Mickael Metesreau

Other Decks in Technology

Transcript

  1. What is Docker? Docker is an open platform for developers

    and sysadmins to build, ship, and run distributed applications. Consisting of Docker Engine, a portable, lightweight runtime and packaging tool, and Docker Hub, a cloud service for sharing applications and automating workflows […] Solomon Hykes, Docker’s Founder & CTO
  2. What is container? Container are to virtual machines as threads

    are to processes. Or you can think of them as chroot on steroids. Will Sargent • More than a sandbox, less than a VM • Deployable and runnable artifact • Lightweight Linux environment
  3. Back in time Server Host OS App Host OS Host

    OS Hypervisor Docker Bin Server Server App App App V os V os Bin Bin App App Bin Bin
  4. Why using container? • We are not only shipping code

    but conf, environment and code • Containers are lightweight, fast, isolated and reproducible environments • Docker provides a simple way to write, version, build, deploy and run environments
  5. #> Run container #> docker images #> docker run -t

    -i ubuntu /bin/bash #> uname -r #> docker images #> docker run -t -i centos /bin/bash #> uname -r #> docker images
  6. #> Run container #> docker pull nginx #> docker run

    --name nginx_inst1 -d nginx #> docker ps #> docker stop nginx_inst1 #> docker ps #> docker ps -a #> docker start nginx_inst1 #> docker ps
  7. #> Container & Host - Network #> docker run --name

    nginx_network -d -p 8080:80 nginx #> curl http://127.0.0.1:8080 #> docker inspect nginx_network | grep IPAddress #> iptables -t nat -L
  8. #> Container & Host - Filesystem #> mkdir /docker_nginx_fs #>

    echo "Hello World!" > /docker_nginx_fs/index2.html #> docker run --name nginx_fs -d -p 8081:80 -v /docker_nginx_fs:/usr/share/nginx/html nginx #> curl http://127.0.0.1:8081/index2.html
  9. #> Dockerfile FROM ubuntu:14.04 RUN \ sed -i 's/# \(.*multiverse$\)/\1/g'

    /etc/apt/sources.list && \ apt-get update && apt-get install -y mono-complete ADD ./publish/ /publish EXPOSE 8123 CMD ["mono", "/publish/HelloWorld.exe"]
  10. #> Build container #> git clone https://github.com/MiKaDoO/nancyfx-ubuntu- docker.git #> docker

    build -t mickael/hello-nancy #> sudo docker run -p 8082:8123 -d mickael/hello-nancy #> curl http://127.0.0.1:8082
  11. #> Your own PAAS Dokuu is a mini-Heroku powered by

    Docker written in less than 100 lines of Bash $ cd node-js-sample $ git remote add dokku [email protected]:node-js-app $ git push dokku master Counting objects: 296, done. Delta compression using up to 4 threads. Compressing objects: 100% (254/254), done. Writing objects: 100% (296/296), 193.59 KiB, done. Total 296 (delta 25), reused 276 (delta 13) -----> Building node-js-app ... Node.js app detected -----> Resolving engine versions ... blah blah blah ... -----> Application deployed: http://node-js-app.dokku.me
  12. One container ok. But how to scale? • Kubernetes by

    Google • Apache Mesos • Marathon • Docker tools • Compose, Swarm, Machine, Hub
  13. How to start? • Custom server • Dedian, Ubuntu, Fedora…

    • Cloud platform • Azure, Digital Ocean, App Engine, Aws… • Your machine • Boot2Docker
  14. How to start? • Docker documentation • DockerCon videos •

    Docker Paris meetup • Pluralsight course • Twitter university