<style> section.present { font-size: 2.5rem; } .footnote { font-size: 1.5rem; } div.reduced { font-size: 0.9em; } .pkpContainer { display: flex; } .pkpCol { flex: 1; width: 48%; } h1.raw { padding-top:5vh } .white img { background: rgb(255, 255, 255, 1) !important; } .reveal .slides section .fragment.highlight-blue.visible { color: black; background: #1b91ff; background: #89c4d5; } .reveal .slides section .fragment.highlight-green.visible { color: black; background: #87deaa; } .reveal .slides section .fragment.highlight-green.visible a { color: black; } .ficha { background: white; color: #333; padding: 4rem 8rem 4rem 8rem; } .right { text-align: right; } .left { text-align: left; } .justify { text-align: justify; } mark { background: #89c4d5; } h1 mark { color: white; } .logo.fixedTop { position: fixed; top: 0vh; right: -24vh; text-align: right; } .logo.fixedTop img { width: 50%; border: 0; background-color: initial; box-shadow: initial; -webkit-filter: grayscale(100%); /* Safari 6.0 - 9.0 */ filter: grayscale(100%); } .highlightMe { background-color: red; } .reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal h6 { text-shadow: 2px 2px #191919; } .alert-warning { padding: 0.1rem 2rem; } .shadow { text-shadow: 2px 2px #191919; color:white; margin: 0; } @media print h1, h2, h3, h4, h5 { text-shadow: 2px 2px #191919; color:white; margin: 0; } /** overlap **/ .image-float { float: left; position: relative; top: 0; left: 0; } .reveal .content-aside { margin-top: 1em; } </style> <!-- .slide: data-background="https://i.imgur.com/5piZ1ur.png"--> # ==DOCKER for DUMMIES== #### (a light-hearted introduction to the wonderful world of containers) ---- <!-- .slide: data-background="https://i.imgur.com/qV04Z9n.png"--> # YEP, THIS IS A TECHNICAL WORKSHOP #### (although adapted for all audiences) <!-- ![MrRobot](https://i.imgur.com/EGSeQLU.png) ![HCF cover](https://i.imgur.com/qV04Z9n.jpg) ![](https://i.imgur.com/zULWXfV.png) ![](https://i.imgur.com/3G0dJdQ.png) ![](https://i.imgur.com/pWKCz0y.png) ![](https://i.imgur.com/KNK5UjY.jpg) --> ---- <!-- .slide: data-background="https://i.imgur.com/s9a1P1x.png"--> &nbsp; &nbsp; &nbsp; &nbsp; # ERGO...<br /> IT WON'T SATISFY ANYONE ### (BUT AT LEAST YOU WILL COME AWAY<br/> WITH A GENERAL IDEA). <!-- ![IT crowd](https://i.imgur.com/s9a1P1x.png) --> ---- <!-- .slide: data-background="https://i.imgur.com/BpbIwMU.png"--> # CONTENTS <div class="ficha"> | 1 | Why we need docker? | :star: | |-------|----------------------------|-----------------------------| | **2** | **What is it and what does it bring?** | :star: :star: | | **3** | **Docker terminology** | :star: :star: | | **4** | **Basic tools** | :star: :star: :star: | | **5** | **Let's play...** | :star: :star: :star: :star: | </div> <br /> ### 80 minutes theory ### 30 minutes practice <!-- ![La fama cuesta](https://i.imgur.com/BpbIwMU.png) --> <!---- ![Docker meme](https://i.imgur.com/bq6qNqG.png) ![Dockers ship](https://i.imgur.com/tORbfT2.jpg =80%x) ![Dockers from air](https://i.imgur.com/9JlZH0V.jpg =80%x) ![Dockers wall](https://i.imgur.com/y28KpiJ.jpg =80%x) ![Dockers in the sky](https://i.imgur.com/fykiG7k.jpg =80%x) ![Docker ship](https://i.imgur.com/tORbfT2.jpg) ![Docker ship color 2](https://i.imgur.com/ASDhBBX.jpg) ![Doomies back](https://i.imgur.com/v8G29NY.png) ![Doomies hello](https://i.imgur.com/zJwg9Ag.jpg) ![Doomie preocupated](https://i.imgur.com/gPmvA51.png) ![Doomies in the sky](https://i.imgur.com/bbZAu7I.jpg") ![Walking in the fog](https://i.imgur.com/6dly8m1.png) --> ---- <div class="ficha"> BIO (TBD if somebody asks for it) </div> --- # THE PROBLEM ![Solomon Hykes quote](https://i.imgur.com/4h7tSE1.png) <span class="footnote">Source: https://www.cio.com/article/2924995/what-are-containers-and-why-do-you-need-them.html</span> <span class="footnote">Vídeo: https://www.youtube.com/watch?v=Q5POuMHxW-0</span> <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> ---- # ¿THE REASONS? <div class="ficha"> To manage diversity in a structured way: | **Multiple stacks** | **Multiple targets** | | ------------------- | ---------------------------------- | | Lenguages | Local development | | Versions | Preproduction | | Frameworks | Testing / Quality Assurance (QA) | | Libraries | Staging | | Databases | Production: iron, cloud, hybrid... | | ... | ... | </div> ---- ## THE MATRIX FROM HELL ![Matrix from hell](https://i.imgur.com/YeH3f56.png =80%x) ---- <!-- .slide: data-background="https://i.imgur.com/VGRxS7D.png"--> ### SISYPHUS SYNDROME ### (according to the DSM it is the main cause of ‘[BOFH](https://es.wikipedia.org/wiki/Bastard_Operator_from_Hell)’) <!-- ![Sisifo](https://i.imgur.com/VGRxS7D.png) --> ---- ### IS THIS A NEW PROBLEM? ![Real dockers matrix](https://i.imgur.com/sSaFQzK.png =90%x) ---- <!-- .slide: data-background="https://i.imgur.com/46Up4fk.png"--> # ¡containers! <!-- ![Docker ship color 1](https://i.imgur.com/46Up4fk.jpg) --> ---- ## IN FACT: THE TECHNOLOGY ALREADY EXISTED... <div style="width:100%; height:500px; overflow-y:scroll;"> <img src="https://i.imgur.com/pzeDxA4.png" style="max-height: initial;width:100%;" /> </div> <span class="footnote">Source: https://www.plesk.com/blog/business-industry/infographic-brief-history-linux-containerization</span> **1978 chroot** > 2000 jails > 2007 cgroups > **2008 linuxContainers** > 2013 docker <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> <!-- {%slideshare Pivotal/the-history-44807468 %} ![](https://i.imgur.com/GQL1HDn.png) <span class="footnote">Fuente: [Roy, Gareth & Washbrook, Andrew & Crooks, David & Qin, Gang & Skipsey, Samuel & Stewart, Gordon & Britton, David. (2015). Evaluation of containers as a virtualisation alternative for HEP workloads. Journal of Physics: Conference Series. 664. 022034. 10.1088/1742-6596/664/2/022034. ](https://www.researchgate.net/publication/288039950_Evaluation_of_containers_as_a_virtualisation_alternative_for_HEP_workloads/figures?lo=1)</span> --> ---- <!-- ![Docker logo](https://i.imgur.com/ZgbuUpN.png) --> <!-- .slide: data-background="https://i.imgur.com/ZgbuUpN.png"--> # Docker succeeds<br/>because it makes it so easy. ---- ## ==And because it is, uses and distributes FLOSS...== <!-- .slide: data-background="https://i.imgur.com/gZ3nZJt.jpg"--> ![imagen](https://hackmd.io/_uploads/r1MWspnmkl.png) <!-- ![](https://i.imgur.com/gZ3nZJt.png) --> <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> --- <!-- .slide: data-background="https://i.imgur.com/fzu9wWo.png"--> <br /> <br /> <br /> <br /> <br /> # A DEFINITION PLEASE? <!-- ![Socrates](https://i.imgur.com/fzu9wWo.png) --> ---- <!-- .slide: data-background="https://i.imgur.com/ZzJ6o4A.jpg"--> <div class="ficha"> **Docker is a tool for <span><!-- .element: class=‘fragment highlight-blue’ data-fragment-index=‘1’ -->packaging an application together with its dependencies</span> (libraries, configuration, data...).** This guarantees portability and at the same time, has very positive side effects such as: isolation, replication, adaptability, integration, recycling, agility, resilience, backup... </div> <!-- Docker Benefits Fast (deployment, migration, restarts) Secure Lightweight (save disk & CPU) Portable software Microservices and integrations (APIs) Simplify DevOps Open Source Version control capabilities --> <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> ---- ## PORTABILITY AND CONSISTENCY <div class="image-float"> <p style="position: relative; left: 0; top: 0;"> <img src="https://i.imgur.com/vSSWTzx.png" width="50%"/> </p> <p class="fragment" data-fragment-index="1" style="position:absolute; left: 0; top: 0;"> <img src="https://i.imgur.com/C2V6NR2.png" width="50%"/> </p> </div> From Development to Production (and vice versa) **Staging > Continuous Integration** <!-- ![it works](https://i.imgur.com/vSSWTzx.png =50%x) --> <!-- ![it works forbidden](https://i.imgur.com/C2V6NR2.png =50%x) --> <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> ---- ## PETS VS. CATTLE Replication, scalability, testing, high availability... ![](https://i.imgur.com/45OfHcr.png) [The History of Pets vs Cattle and How to Use the Analogy Properly](http://cloudscaling.com/blog/cloud-computing/the-history-of-pets-vs-cattle)<br/> ~ Posted on Sep 29, 2016 by Randy Bias <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> ---- ## INSULATION On its own, it does not guarantee safety, but it is an improvement on the classic model. ![](https://i.imgur.com/iWMk2H1.png =50%x) <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> ---- ## ADAPTABILITY As containers can be easily created and destroyed, the system can respond to demand. {%youtube CZ3wIuvmHeM %} ---- ## "LEGO" DEVELOPMENT The modularity offered by micro-services makes it possible to think of developments at a very high level, by means of intercommunicating black boxes with different functions. ![](https://i.imgur.com/dU7ZQ0c.png) <span class="footnote">Más info: https://mobyproject.org</span> <!-- ![](https://i.imgur.com/57GvgDM.png =80%x) --> ---- ## VERSION CONTROL ![](https://i.imgur.com/YvXRuPw.png) Docker uses git to manage the different versions of the images. ---- ## EFFICIENCY <div class="reduced"> A virtual machine (VM) needs to contain the entire operating system. <span><!-- .element: class="fragment highlight-blue" data-fragment-index="1" -->Containers take advantage of the host OS</span> on which they run (they share kernel and even libraries). Containers are lighter, faster and consume fewer resources (disk, memory and CPU), but they cannot run operating systems other than the host.</div> ![](https://i.imgur.com/MDrOalM.png =70%x) <span class="footnote">Source: https://subscription.packtpub.com/book/virtualization_and_cloud/9781783981786/1/ch01lvl1sec9/virtualization-with-proxmox-ve</span> < <!-- ![](https://i.imgur.com/LHDD9CE.png =70%x) --> <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> ---- ### ¿CONTAINERS vs VIRTUAL MACHINES? {%youtube FWpnbGnzk08 %} ---- ### BOTH TECHNOLOGIES ARE GOOD<br/>BUT CONTAINERS ARE WINNING.... ;-) ![imagen](https://hackmd.io/_uploads/r1vpKjamJe.png) Source: https://trends.google.es/trends/explore?date=all&q=docker,vmware&hl=en ---- ### WHO USES DOCKER? **Google:** https://www.youtube.com/watch?v=tsk0pWf4ipw **Netflix:** https://www.youtube.com/watch?v=CZ3wIuvmHe*M ![Projects using docker](https://i.imgur.com/gR2UhAu.png =65%x) <span class="footnote">Source: https://stackshare.io/docker More information: https://www.featuredcustomers.com/vendor/docker/customers</span> ---- ### WHO USES DOCKER? <div style="width: 90%; margin: auto;"> | <a href="https://i.imgur.com/4OaaAha.png">![](https://i.imgur.com/4OaaAha.png)</a> | <a href="https://i.imgur.com/24K2iSa.png">![](https://i.imgur.com/24K2iSa.png)</a> | |---|---| | <a href="https://i.imgur.com/OhffrSi.png">![](https://i.imgur.com/OhffrSi.png)</a> | <a href="https://i.imgur.com/xnXPj7i.png">![](https://i.imgur.com/xnXPj7i.png) </a> | </div> <span class="footnote">From: <a href="https://www.datadoghq.com/docker-adoption">https://www.datadoghq.com/docker-adoption</a></span> --- # BEFORE CONTINUING... <br/>ONE LAST CONCEPT <!-- ![](https://i.imgur.com/RpOS49q.png) --> ---- <!-- .slide: data-background="https://i.imgur.com/QsGCYKA.png"--> <!-- ![Monolito mono](https://i.imgur.com/QsGCYKA.png) --> ## MONOLITH vs MULTISERVICES <div class="image-float"> <p style="position: relative; left: 0; top: 0;"> <img src="https://i.imgur.com/wHolORp.png" width="75%"/> </p> <p class="fragment" data-fragment-index="1" style="position:absolute; left: 0; top: 0;"> <img src="https://i.imgur.com/iuZlAB3.png" width="75%"/> </p> <p class="fragment" data-fragment-index="2" style="position:absolute; left:0; top: 0;"> <img src="https://i.imgur.com/2A3OKwl.png" width="75%"/> </p> <p class="fragment" data-fragment-index="3" style="position:absolute; left:0; top: 0;"> <img src="https://i.imgur.com/X6fKmOR.png" width="75%"/> </p> </div> <!-- ![abstracto](https://i.imgur.com/wHolORp.png) ![monolito](https://i.imgur.com/iuZlAB3.png) ![omeka classic](https://i.imgur.com/2A3OKwl.png) ![omeka s](https://i.imgur.com/X6fKmOR.png) --> <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> --- <!-- .slide: data-background="https://i.imgur.com/90KffET.png"--> # PARADIGM SHIFT <div class="ficha"> | BEFORE | > NOW... | | --------------------------- | ------------------------------- | | > Monolithic applications | > Decoupled services | | > Long development cycles | > Rapid, iterative enhancements | | > Planned scaling | > Dynamic scaling | | > Single environment/server | > Multiple environments/servers | </div> <!-- ![ENIAC](https://i.imgur.com/90KffET.png) --> --- <!-- .slide: data-background="https://i.imgur.com/G38K1rh.jpg" --> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> # MAYBE...<br /> SHOULD WE USE DOCKER? <!-- ![Me he dejado el gas abierto](https://i.imgur.com/G38K1rh.jpg) --> --- ## ¿QUÉ VERSIONES HAY? ![](https://i.imgur.com/D8ewm1y.png =50%x) <span class="footnote">Fuente: https://collabnix.com/demystifying-the-relationship-between-moby-docker</span> Para empezar: [Docker Comunity Edition](https://docs.docker.com/install) Diseñado primero para GNU/Linux, también funciona sobre MacOS y Windows. ---- ## ¿CÓMO SE INSTALA? ```bash= ### Fuente: https://docs.docker.com/install/linux/docker-ce/debian/ ### AVISO: Este script es para Debian. No usar para ubuntu. ### Garantizar que no hay instalaciones previas: $ sudo apt-get remove docker docker-engine docker.io containerd runc ### Añadir dependencias $ sudo apt update $ sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common ### Añadir el repositorio de docker-ce $ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - $ sudo apt-key fingerprint 0EBFCD88 $ sudo sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" ### Instalar docker-ce $ sudo apt update $ sudo apt-get install docker-ce docker-ce-cli containerd.io ### Confirmar que el servicio está corriendo: $ sudo systemctl status docker ### Provar creando contenedor "hola mundo" $ sudo docker run hello-world ### Opcional: Ahorrarse el sudo $ sudo usermod -aG docker ${USER} ### Y reiniciar la sesión o hacer "su - ${USER}". ### Para añadir nuevos usuarios al grupo docker: $ sudo usermod -aG docker <username> ``` Para el resto de sistemas operativos: https://docs.docker.com/install (También para Windows) <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> ---- <iframe width="100%" height="500px" src="https://labs.play-with-docker.com/" frameborder="0" style="background-color:white;"></iframe> URL: https://labs.play-with-docker.com <span class="footnote">(Nota: La web embedida puede fallar. Si sucede, usa el enlace.)</span> <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> --- <!-- .slide: data-background="https://i.imgur.com/6udxtDa.png"--> # CONCEPTOS BÁSICOS ### (muy, muy básicos) <!-- ![Ballena y barco](https://i.imgur.com/CV9CUdJ.jpg) --> <!-- ![Ballena con velas](https://i.imgur.com/6udxtDa.png) --> ---- ### TERMINOLOGÍA ESENCIAL <!-- .slide: data-background="https://i.imgur.com/iyYvuoK.jpg"--> <div class="pkpContainer"> <div class="pkpCol"> ![Docker workflow](https://i.imgur.com/NiMnJbN.png =60%x) </div> <div class="pkpCol" style="padding-top: 2rem; margin-left: -4rem; text-align: left;"> <span><!-- .element: class="fragment highlight-blue" data-fragment-index="1" -->**Dockerfile:** Las instrucciones para construir la imagen. ["La receta"]</span> <span><!-- .element: class="fragment highlight-blue" data-fragment-index="2" -->**Imagen:** El modelo abstracto de contenedor. ["El molde"]</span> <span><!-- .element: class="fragment highlight-green" data-fragment-index="3" -->**Contenedor:** La concreción de una imagen abstracta. ["La galleta"]</span> <span><!-- .element: class="fragment highlight-green" data-fragment-index="4" -->**Volumen:** Los datos, que pueden ser persistentes o volátiles. ["¿El plato?"]</span> <br /> :::warning :warning: ***Los contenedores son volátiles*** Mascota vs ganado: Si falla, se sacrifica y se vuelven a generar. ::: </div> </div> <div style="clear:both;" /> <!-- ![cow cookie cutter](https://i.imgur.com/iyYvuoK.jpg) --> <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> ---- ### RADIOGRAFÍA DE UN DOCKERFILE #### (las "recetas") ```dockerfile= FROM php:apache # Omeka-S web publishing platform for digital heritage collections (https://omeka.org/s/) # Initial maintainer: Oldrich Vykydal (o1da) - Klokan Technologies GmbH MAINTAINER Eric Dodemont <eric.dodemont@skynet.be> RUN a2enmod rewrite ENV DEBIAN_FRONTEND noninteractive RUN apt-get -qq update && apt-get -qq -y upgrade RUN apt-get -qq update && apt-get -qq -y --no-install-recommends install \ unzip \ libfreetype6-dev \ libjpeg62-turbo-dev \ libmcrypt-dev \ libpng-dev \ libjpeg-dev \ libmemcached-dev \ zlib1g-dev \ imagemagick \ libmagickwand-dev # Install the PHP extensions we need RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ RUN docker-php-ext-install -j$(nproc) iconv pdo pdo_mysql mysqli gd RUN pecl install mcrypt-1.0.2 && docker-php-ext-enable mcrypt && pecl install imagick && docker-php-ext-enable imagick # Add the Omeka-S PHP code COPY ./omeka-s-1.4.0.zip /var/www/ RUN unzip -q /var/www/omeka-s-1.4.0.zip -d /var/www/ \ && rm /var/www/omeka-s-1.4.0.zip \ && rm -rf /var/www/html/ \ && mv /var/www/omeka-s/ /var/www/html/ COPY ./imagemagick-policy.xml /etc/ImageMagick/policy.xml COPY ./.htaccess /var/www/html/.htaccess # Add some Omeka modules COPY ./omeka-s-modules-v4.tar.gz /var/www/html/ RUN rm -rf /var/www/html/modules/ \ && tar -xzf /var/www/html/omeka-s-modules-v4.tar.gz -C /var/www/html/ \ && rm /var/www/html/omeka-s-modules-v4.tar.gz # Add some themes COPY ./centerrow-v1.4.0.zip ./cozy-v1.3.1.zip ./thedaily-v1.4.0.zip /var/www/html/themes/ RUN unzip -q /var/www/html/themes/centerrow-v1.4.0.zip -d /var/www/html/themes/ \ && unzip -q /var/www/html/themes/cozy-v1.3.1.zip -d /var/www/html/themes/ \ && unzip -q /var/www/html/themes/thedaily-v1.4.0.zip -d /var/www/html/themes/ \ && rm /var/www/html/themes/centerrow-v1.4.0.zip /var/www/html/themes/cozy-v1.3.1.zip /var/www/html/themes/thedaily-v1.4.0.zip # Create one volume for files and config RUN mkdir -p /var/www/html/volume/config/ && mkdir -p /var/www/html/volume/files/ COPY ./database.ini /var/www/html/volume/config/ RUN rm /var/www/html/config/database.ini \ && ln -s /var/www/html/volume/config/database.ini /var/www/html/config/database.ini \ && rm -Rf /var/www/html/files/ \ && ln -s /var/www/html/volume/files/ /var/www/html/files \ && chown -R www-data:www-data /var/www/html/ \ && chmod 600 /var/www/html/volume/config/database.ini \ && chmod 600 /var/www/html/.htaccess VOLUME /var/www/html/volume/ CMD ["apache2-foreground"] ``` <span class="footnote">Fuente: https://github.com/dodeeric/omeka-s-docker/blob/master/Dockerfile Recuerda: [Monolítico vs Micro-servicios](https://hackmd.io/@marcbria/docker4ojs#/5/1)</span> ---- <!-- .slide: data-background="https://i.imgur.com/V2XlWJO.jpg"--> <!-- ![Cooking table](https://i.imgur.com/V2XlWJO.jpg) --> # UTENSILIOS E INGREDIENTES <br /> <div class="pkpContainer reduced" style="background-color: white; color: black; padding: 4rem; 2rem 4rem 0rem;"> <div class="pkpCol" style=""> ## ==DEFINICIÓN== - **FROM:** define la IMAGEN BASE (nuestro punto de partida). - **ENV:** define variables de entorno. - **EXPOSE:** abre puertos del contenedor. - **WORKDIR:** directorio de trabajo. - **USER:** usuario y grupo. </div> <div class="pkpCol"> ## ==ACCIÓN== - **COPY:** copia dentro del contenedor (ver ADD). - **RUN:** ejecuta un comando. - **VOLUME:** crea un volumen. - **CMD:** define el programa que ejecutará el contenedor. (ver ENTRYPOINT). </div> </div> [¿Quieres saber más?](https://docs.docker.com/engine/reference/builder) ---- <!-- .slide: data-background="https://i.imgur.com/G5N3D3v.jpg"--> <!-- ![](https://i.imgur.com/G5N3D3v.jpg) --> ### EL CIRCUITO DOCKER <div class="pkpContainer reduced"> <div class="pkpCol"> ![Docker workflow commands](https://i.imgur.com/ddBjk7s.png =60%x) </div> <div class="pkpCol" style="padding-top: 10rem; margin-left: -4rem; text-align: left;"> <span><!-- .element: class="fragment highlight-blue" data-fragment-index="1" -->1) **Dockerfile:** El Dockerfile se construye ("build") para crear una "imagen":</span> ```bash= $ docker build [options] ``` <span><!-- .element: class="fragment highlight-green" data-fragment-index="2" -->2) **Imagen:** La "imagen" se ejecuta ("run") para crear un "contendor":</span> ```bash= $ docker run [options] image-name ``` <span><!-- .element: class="fragment highlight-blue" data-fragment-index="3" -->1-2) **Contenedor:** En la definición (Dockerfile) o al iniciarlos, los "contendores" incluyen o se asocian a "volúmenes".</span> ```bash= $ docker run [options] -v ./web:/var/www/html img-name ``` </div> </div> <div style="clear:both;" /> <div class="logo fixedTop"> ![Alarma](https://i.imgur.com/mbztOms.png) </div> ---- # COMANDOS BÁSICOS <div class="pkpContainer reduced"> <div class="pkpCol" style=" text-align: left;"> - **build:** CONSTRUIR una imagen a partir del Dockerfile del directorio actual: ```bash= $ docker build ``` - **run:** CREAR un contenedor: ```bash= $ docker run [options] [containerIDoName] ``` - **ps:** VER los contenedores en funcionamiento (con "-a" para verlos todos, incluso los detenidos): ```bash= $ docker ps $ docker ps -a ``` </div> <div class="pkpCol" style="text-align: left;"> - **stop:** DETENER un contenedor: ```bash= $ docker stop [containerIDoName] ``` - **start:** LEVANTAR un contenedor: ```bash= $ docker start [containerIDoName] ``` - **logs:** Ver los últimos REGISTROS: ```bash= $ docker logs [containerIDoName] ``` - **rm:** BORRA un contenedor detenido: ```bash= $ docker rm [containerIDoName] ``` </div> </div> <div style="clear:both;" /> ---- # ¿OS ACORDÁIS DE LOS MICROSERVICIOS? <div class="pkpContainer reduced"> <div class="pkpCol" style=" text-align: left;"> ![abstracto](https://i.imgur.com/wHolORp.png) </div> <div class="pkpCol" style="text-align: left;"> ![omeka s](https://i.imgur.com/X6fKmOR.png) </div> </div> <div style="clear:both;" /> ---- <!-- .slide: data-background="https://i.imgur.com/KHunBKP.png"--> <!-- ![Monolito room](https://i.imgur.com/KHunBKP.png)--> ### Con un solo Dockerfile encapsulamos<br />pero volvemos a tener un MONOLITO ## ¿PODEMOS CONSTRUIR<br />UN PUZZLE DE DOCKERS? ![](https://i.imgur.com/R1M2sd4.png) ---- <!-- .slide: data-background="https://i.imgur.com/Ab1vI70.png"--> <!-- ![Docker compose](https://i.imgur.com/Ab1vI70.png) --> ---- ![](https://i.imgur.com/GFLTN88.png) <span class="footnote">Fuente: https://docs.docker.com/compose/compose-file </span> ---- # DOCKER-COMPOSE.YML ```yaml= version: "2" services: mariadb: image: mariadb:latest restart: always networks: - network1 volumes: - mariadb:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: blabla MYSQL_DATABASE: omeka MYSQL_USER: omeka MYSQL_PASSWORD: omeka pma: depends_on: - mariadb image: phpmyadmin/phpmyadmin:latest restart: always networks: - network1 ports: - "8080:80" links: - mariadb:db omeka: depends_on: - mariadb image: dodeeric/omeka-s:latest restart: always networks: - network1 ports: - "80:80" links: - mariadb:db volumes: - omeka:/var/www/html/volume volumes: mariadb: omeka: networks: network1: ``` <span class="footnote">Fuente: https://github.com/dodeeric/omeka-s-docker/blob/master/docker-compose.yml </span> --- <!-- .slide: data-background="https://i.imgur.com/dwL3KdC.jpg"--> # ¿VAMOS A JUGAR? ---- <!-- .slide: data-background="https://i.imgur.com/lzT2qDL.jpg"--> <!-- ![](https://i.imgur.com/lzT2qDL.jpg) --> ## REGLAS - <span><!-- .element: class="fragment highlight-blue" data-fragment-index="1" -->"La 1ª regla del Club de la lucha es: nadie habla sobre el Club de la lucha".</span> - <span><!-- .element: class="fragment highlight-blue" data-fragment-index="2" --> La práctica se realiza sobre una plataforma llamada katakoda. DISCLAIMER: Y nunca lo he probado con tanta gente. </span> - <span><!-- .element: class="fragment highlight-blue" data-fragment-index="3" -->Iremos todos juntos (avanzando a la velocidad del búfalo más lento).</span> - <span><!-- .element: class="fragment highlight-blue" data-fragment-index="4" -->¿Te sientes inseguro/a? Busca un/a compañero/a con cara de experto/a.</span> - <span><!-- .element: class="fragment highlight-blue" data-fragment-index="5" -->Si surgen dudas, levantad la mano y nos paramos.</span> No dejaremos nadie a atrás. - <span><!-- .element: class="fragment highlight-blue" data-fragment-index="6" -->Hay más ejercicios que tiempo. Podéis continuar en casa</span>. &nbsp; #### Yo ya se y me aburro. ¿Puedo ir por libre adelantando ejercicios? - Claro, pero lee el anunciado varias veces. - Si te pierdes... estás solo/a. - Si tienes dudas, hablamos al terminar. ---- ## PRÁCTICA 1 <div class="pkpContainer reduced"> <div class="pkpCol" style=" text-align: left;"> ![Ejercicio Deploy HTML](https://i.imgur.com/eMEUCeM.png) </div> <div class="pkpCol" style="text-align: left; padding-top: 6rem;"> En este ejercicio aprenderás a crear una imagen Docker que contenga un sitio web estático sobre un servidor web Nginx. Algunos comandos intimidan un poco, pero la idea es simple. Vamos a construir la siguiente "pila" (en inglés le llaman "stack"): - Web estática: index.html - Servidor web: Nginx - Sistema operativo: alpine [Ir al ejercicio](https://www.katacoda.com/courses/docker/create-nginx-static-web-server) </div> </div> <div style="clear:both;" /> ---- ## PRÁCTICA 2 <div class="pkpContainer reduced"> <div class="pkpCol" style=" text-align: left;"> ![Ejercicio Creating Networks](https://i.imgur.com/ap1Xv2R.png) </div> <div class="pkpCol" style="text-align: left; padding-top: 4rem;"> Si queremos desacoplar los servicios, debemos construir múltiples contenedores y comunicarlos entre si. Esto se puede hacer "a mano" pero es tedioso. Para coordinar distintos contenedores que funcionan conjuntamente, se ha creado Docker Compose (hay quien lo llama orquestrador). En el siguiente ejercicio vamos a ver como crear un docker-compose.yml para iniciar y comunicar distintos distintos servicios. [Ir al ejercicio](https://www.katacoda.com/courses/docker/11) </div> </div> <div style="clear:both;" /> ---- ## ME ABUUUURROOO... ![](https://i.imgur.com/R298YTs.png) [Ir al curso](https://www.katacoda.com/courses/docker) ---- <!-- .slide: data-background="https://i.imgur.com/xu9lfxU.png"--> <!-- ![SpaceShip Troopers](https://i.imgur.com/xu9lfxU.png) --> # ¿Quiere saber más? - https://www.freecodecamp.org/news/comprehensive-introductory-guide-to-docker-vms-and-containers-4e42a13ee103/ - https://devhints.io/docker - https://github.com/wsargent/docker-cheat-sheet --- # GRACIAS #### Marc Bria Ramírez Servei de publicacions de la UAB PKP's technical committee (at large member) ##### marc.bria@uab.es <br /> <br /> <span class="footnote"> **AVISO:** Ningún animal ha sido dañado durante esta presentación. </span>
{"title":"An introduction to docker (2024)","slideOptions":"{\"transition\":\"slide\",\"allottedMinutes\":120,\"defaultTiming\":120,\"previewLinks\":true}","description":"    ","contributors":"[{\"id\":\"2facdac7-0192-4693-87e8-442f43b2b059\",\"add\":36353,\"del\":7797,\"latestUpdatedAt\":null}]"}
    108 views