Share
Embed
Transcript
71 slides
-
Container Engine? Basé sur les instructions Linux LXC Isolation des
processus et des ressources "chroot" sur-vitaminé / VM super légères -
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 -
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 -
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 -
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 -
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 -
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 -
$ docker ps CONTAINER ID ... PORTS
923cb190dbc3 ... 0.0.0.0:49155-‐>80/tcp ! $ curl http://localhost:49155 <html> <head> <title>Welcome to nginx!</title> ... -
$ docker ps CONTAINER ID ... PORTS
923cb190dbc3 ... 0.0.0.0:49155-‐>80/tcp ! $ curl http://localhost:49155 <html> <head> <title>Welcome to nginx!</title> ... -
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"] -
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"] -
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"] -
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"] -
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"] -
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"] -
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"] -
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"] -
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"] -
• 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 -
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 -
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 -
Réseau Lier des containers entre eux "Service Discovery" facilité Design
pattern "Ambassador" (portabilité) -
$ docker run -‐-‐name redis phptour/redis ! $ docker
run -‐-‐link redis:db phptour/symfony2 -
$ docker run -‐-‐name redis phptour/redis ! $ docker
run -‐-‐link redis:db phptour/symfony2 -
$ docker run -‐-‐name redis phptour/redis ! $ docker
run -‐-‐link redis:db phptour/symfony2 -
Volumes Comme NFS pour Docker (sauf que ça marche) Stocker
des données dans des "Data Containers" Backup aisé des "Data Containers" -
$ docker run -‐-‐name data phptour/data ! $ docker
run -‐-‐volumes-‐from data -‐-‐name mysql phptour/mysql -
$ docker run -‐-‐name data phptour/data ! $ docker
run -‐-‐volumes-‐from data -‐-‐name mysql phptour/mysql -
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/ -
$ 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 -
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 ... -
Environnements de Dev. Intégration continue Parallélisation de tests automatiques Pré-production
continue Déploiement continu Déploiement Green/Blue PaaS Privé ... -
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 -
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 -
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 -
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