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

Introduction à Docker

Introduction à Docker

ubermuda

June 23, 2014

Transcript

71 slides
  1. Container Engine? Basé sur les instructions Linux LXC Isolation des

    processus et des ressources "chroot" sur-vitaminé / VM super légères
  2. Host OS Hypervisor Guest OS Guest OS Guest OS Guest

    OS App App App App Host OS Docker + LXC App App App App VMs vs Containers
  3. VMs vs Containers LXC / Jails / Zones / etc

    Utilise le noyaux de l'hôte Démarre en quelques secondes Pas de ressources Facile à distribuer Hypervisor Démarre un OS complet Démarre en quelques minutes Ressources de l'OS invité Images de plusieurs Go
  4. root@21d86a0b8387:/#  apt-­‐get  install  nginx   root@21d86a0b8387:/#  exit   ! $

     docker  ps  -­‐q  -­‐n  1   21d86a0b8387   ! $  docker  commit  21d86a0b8387  phptour/nginx   240198b750c3cc950c60005d6d24cae4fc2dbcc6c31e274574af68d4a2e8   ! $  docker  images   REPOSITORY                TAG                  IMAGE  ID   phptour/nginx          latest            240198b750c3
  5. root@21d86a0b8387:/#  apt-­‐get  install  nginx   root@21d86a0b8387:/#  exit   ! $

     docker  ps  -­‐q  -­‐n  1   21d86a0b8387   ! $  docker  commit  21d86a0b8387  phptour/nginx   240198b750c3cc950c60005d6d24cae4fc2dbcc6c31e274574af68d4a2e8   ! $  docker  images   REPOSITORY                TAG                  IMAGE  ID   phptour/nginx          latest            240198b750c3
  6. root@21d86a0b8387:/#  apt-­‐get  install  nginx   root@21d86a0b8387:/#  exit   ! $

     docker  ps  -­‐q  -­‐n  1   21d86a0b8387   ! $  docker  commit  21d86a0b8387  phptour/nginx   240198b750c3cc950c60005d6d24cae4fc2dbcc6c31e274574af68d4a2e8   ! $  docker  images   REPOSITORY                TAG                  IMAGE  ID   phptour/nginx          latest            240198b750c3
  7. root@21d86a0b8387:/#  apt-­‐get  install  nginx   root@21d86a0b8387:/#  exit   ! $

     docker  ps  -­‐q  -­‐n  1   21d86a0b8387   ! $  docker  commit  21d86a0b8387  phptour/nginx   240198b750c3cc950c60005d6d24cae4fc2dbcc6c31e274574af68d4a2e8   ! $  docker  images   REPOSITORY                TAG                  IMAGE  ID   phptour/nginx          latest            240198b750c3
  8. $  docker  ps   CONTAINER  ID    ...    PORTS

      923cb190dbc3    ...    0.0.0.0:49155-­‐>80/tcp   ! $  curl  http://localhost:49155   <html>   <head>   <title>Welcome  to  nginx!</title>   ...
  9. $  docker  ps   CONTAINER  ID    ...    PORTS

      923cb190dbc3    ...    0.0.0.0:49155-­‐>80/tcp   ! $  curl  http://localhost:49155   <html>   <head>   <title>Welcome  to  nginx!</title>   ...
  10. FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install

     -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]
  11. FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install

     -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]
  12. FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install

     -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]
  13. FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install

     -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]
  14. FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install

     -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]
  15. FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install

     -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]
  16. FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install

     -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]
  17. FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install

     -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]
  18. FROM  stackbrew/ubuntu   ENV  DEBIAN_FRONTEND  noninteractive   RUN  apt-­‐get  install

     -­‐y  nginx   ADD  nginx.conf  /etc/nginx/nginx.conf   EXPOSE  80   VOLUME  ["/var/www"]   CMD  ["-­‐g",  "daemon  off;"]   ENTRYPOINT  ["nginx"]
  19. • Docker CLI • run -d, attach, wait, ps, images,

    rm, rmi, etc • Réseau • Ambassador, advanced routing, etc • Volumes • Data containers, bindmounting, etc • Docker Index • thousands of ready-made images • Docker Registry • private Docker Index, Docker Hub, etc • Remote API • dockerode, Docker-PHP, etc
  20. Docker CLI • run  [-­‐d] : exécuter un container •

    attach : attacher stdout / stdin • ps : lister les containers • images : lister les images • rm  /  rmi : supprimer des containers / images
  21. Usage:  docker  [OPTIONS]  COMMAND  [arg...]    -­‐H=[unix:///var/run/docker.sock]:  tcp://host:port  to  bind/connect

     to  or  unix://path/to/socket  to  use   ! A  self-­‐sufficient  runtime  for  linux  containers.   ! Commands:          attach        Attach  to  a  running  container          build          Build  a  container  from  a  Dockerfile          commit        Create  a  new  image  from  a  container's  changes          cp                Copy  files/folders  from  the  containers  filesystem  to  the  host  path          diff            Inspect  changes  on  a  container's  filesystem          events        Get  real  time  events  from  the  server          export        Stream  the  contents  of  a  container  as  a  tar  archive          history      Show  the  history  of  an  image          images        List  images          import        Create  a  new  filesystem  image  from  the  contents  of  a  tarball          info            Display  system-­‐wide  information          inspect      Return  low-­‐level  information  on  a  container          kill            Kill  a  running  container          load            Load  an  image  from  a  tar  archive          login          Register  or  Login  to  the  docker  registry  server          logs            Fetch  the  logs  of  a  container          port            Lookup  the  public-­‐facing  port  which  is  NAT-­‐ed  to  PRIVATE_PORT          ps                List  containers          pull            Pull  an  image  or  a  repository  from  the  docker  registry  server          push            Push  an  image  or  a  repository  to  the  docker  registry  server          restart      Restart  a  running  container          rm                Remove  one  or  more  containers          rmi              Remove  one  or  more  images          run              Run  a  command  in  a  new  container          save            Save  an  image  to  a  tar  archive          search        Search  for  an  image  in  the  docker  index          start          Start  a  stopped  container          stop            Stop  a  running  container          tag              Tag  an  image  into  a  repository          top              Lookup  the  running  processes  of  a  container          version      Show  the  docker  version  information          wait            Block  until  a  container  stops,  then  print  its  exit  code
  22. $  docker  run  -­‐-­‐name  redis  phptour/redis   ! $  docker

     run  -­‐-­‐link  redis:db  phptour/symfony2
  23. $  docker  run  -­‐-­‐name  redis  phptour/redis   ! $  docker

     run  -­‐-­‐link  redis:db  phptour/symfony2
  24. $  docker  run  -­‐-­‐name  redis  phptour/redis   ! $  docker

     run  -­‐-­‐link  redis:db  phptour/symfony2
  25. Volumes Comme NFS pour Docker (sauf que ça marche) Stocker

    des données dans des "Data Containers" Backup aisé des "Data Containers"
  26. $  docker  run  -­‐-­‐name  data  phptour/data   ! $  docker

     run  -­‐-­‐volumes-­‐from  data  -­‐-­‐name  mysql  phptour/mysql
  27. $  docker  run  -­‐-­‐name  data  phptour/data   ! $  docker

     run  -­‐-­‐volumes-­‐from  data  -­‐-­‐name  mysql  phptour/mysql
  28. Docker Remote API API (à peu près) REST pour Docker

    ! Clients tierce-partie Dockerode, Docker-PHP, etc https://docs.docker.com/reference/api/ remote_api_client_libraries/
  29. $  docker  run  -­‐name  data  phptour/data   ! $  docker

     run  -­‐-­‐volumes-­‐from  data  -­‐-­‐name  mysql  phptour/mysql   ! $  docker  run  -­‐v  $(pwd):/var/www  -­‐-­‐name  php5  phptour/php5   ! $  docker  run  -­‐p  80:80  -­‐v  $(pwd):/var/www  \     -­‐link  php5:php5  \     -­‐link  mysql:mysql  \     phptour/nginx
  30. Pas natif libswarm / libchan ! Beaucoup d'outils tierce-partie :

    ! https://github.com/marmelab/gaudi http://orchardup.github.io/fig/ http://docs.vagrantup.com/v2/docker/index.html ...
  31. Environnements de Dev. Intégration continue Parallélisation de tests automatiques Pré-production

    continue Déploiement continu Déploiement Green/Blue PaaS Privé ...
  32. Environnements de Dev. Intégration continue Parallélisation de tests automatiques Pré-production

    continue Déploiement continu Déploiement Green/Blue PaaS Privé ... Développer et packager votre application Symfony2 avec Docker et Vagrant Demain 13:45, Salle 3
  33. Environnements de Dev. Intégration continue Parallélisation de tests automatiques Pré-production

    continue Déploiement continu Déploiement Green/Blue PaaS Privé ... drone.io
  34. Environnements de Dev. Intégration continue Parallélisation de tests automatiques Pré-production

    continue Déploiement continu Déploiement Green/Blue PaaS Privé ... stage1.io
  35. Environnements de Dev. Intégration continue Parallélisation de tests automatiques Pré-production

    continue Déploiement continu Déploiement Green/Blue PaaS Privé ... wercker.com

More Decks by ubermuda

Other Decks in Programming