Oscar Garcia Poblacion
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: docker, contenedores title: Introducción a la tecnología de contenedores slideOptions: transition: slide theme: white --- <style> .reveal section img { background:none; border:none; box-shadow:none; } </style> # Introducción a la tecnología de contenedores --- ## Definición de Wikipedia > an open-source project that automates the deployment of software applications inside containers by providing an additional layer of abstraction and automation of OS-level virtualization on Linux. --- ## Características principales - Es una herramienta software - Permite desarrollar y empaquetar el código junto con todas sus dependencias en una _imagen_ - Uno o varios _contenedores_ pueden ejecutar de forma aislada una _imagen_ - Los contenedores parecen máquinas virtuales, pero no tienen la sobrecarga de estas últimas y son por lo tanto más eficientes. --- ## Contenedores vs máquinas virtuales - Ventajas de las MV - Mayor aprovechamiento de los recursos - Entorno aislado de ejecución - Facilidad en la distribución: - Aplicaciones - Dependencias - Configuraciones --- - Desventajas: - Arranque (lento) del SO de la MV - Cada MV tiene su propio sistema operativo, posiblemente diferente. - Configuración y aprovisionamiento complejos - La virtualización impone sobrecarga sobre los recursos hw: CPU y MEM - No son portables entre hipervisores diferentes Note: No se pueden migrar las máquinas directamente entre AWS y Google Cloud, por ejemplo. --- ## Contenedores + Los SO tradicionales virtualizan la CPU y la memoria. El sistema de archivos y la red está compartida entre todos los procesos + Las MV virtualizan hardware, sobre el hardware virtualizado corre un SO completo, con sus bibliotecas y ejecutables (decenas de GB's por MV) --- :::success Virtualización del sistema operativo ::: + Cada contenedor incluye solo una aplicación concreta junto con sus dependencias + El sistema operativo no se replica, se comparte entre contenedores + Cada contenedor cree ver su propio sistema operativo --- ## Ventajas de los contenedores - Proporcionan un mecanismo para crear entornos de ejecución aislados dentro de una máquina y bajo un determinado sistema operativo. - Los contenedores se crean en un servidor físico (o virtual) y sobre el sistema operativo de dicho servidor. - La capacidad de ejecución de los contenedores es un servicio del propio sistema operativo --- - Los contenedores son unidades autocontenidas: tienen todo lo necesario para ejecutar una aplicación concreta, y nada más. - Son muy ligeros: arrancan en pocos segundos, mientras que una MV puede tardar minutos. - Los contenedores a su vez pueden ejecutarse en entornos muy diferentes: desde un servidor físico, un cluster con varias máquinas o un servicio cloud. --- ## Tecnología de contenedores :::danger Para poder utilizar contenedores, es necesario que el sistema operativo disponga de esta característica. ::: ![](https://i.imgur.com/pBKkTNc.png =600x) --- ### Contenedores en Linux - Estan basados en una característica del núcleo denominada `cgroups` - Cada `cgroup` de forma aislada dispone de: - Su propio árbol de procesos y PID's - Su propio stack de red - Sus propios usuarios - Su propio sistema de archivos (efímero) - Sin embargo comparte todo el código del núcleo --- ## Docker --- ### ¿Qué es Docker? + Software que facilita la creación y gestión de contenedores + Es un estándar de facto + Se basa en el proyecto LXC [Flockport - LXC vs Docker](https://archives.flockport.com/lxc-vs-docker/) --- ### Terminología Docker + Imagen (de un contenedor) + Es un archivo estático que incluye todo el sistema de archivos, con la aplicación y todas sus dependencias. + Contenedor + Es la entidad que ejecuta una imagen + Puede haber varios contenedores ejecutando la misma imagen Note: - El que puede haber más de un contenedor ejecutando la misma imagen es una forma de aprovechar de forma explícita el paralelismo que proporciona el hecho de tener varias máquinas virtuales ejecutando ese contenedor, o varias CPU en una misma máquina, o una combinación de varias VM, con varias CPU cada una, formando un cluster (kubernetes) --- ## Persistencia de datos + El sistema de archivos que ve un contenedor es la unión de: + Sistema de archivos del anfitrión + Las capas añadidas por la imagen + Una capa de escribible (writable container layer) + Lo que se crea dentro de un contenedor es efímero + La capa escribible no es muy eficiente --- ### Técnicas para persistir datos + Utilizando volúmenes + Utilizando puntos de montaje + Utilizando `tmpfs` Cualquiera de las tres son transparentes para el contenedor --- ### Volúmenes + Son gestionados por `docker` + Archivos especiales dentro del anfitrión + Almacenamiento en algún sistema remoto (cloud) + Puede ser utilizados a la vez por varios contenedores + Sobreviven a la finalización de los contenedores --- ### Puntos de montaje + Hacen corresponder una ruta del anfitrión con un punto dentro del contenedor. + Muy eficientes, pero dependen del SdA del anfitrión + Muy útiles para desarolladores 😉 --- ## Uso de Docker durante la etapa de desarrollo + El SW tiene dependencias de terceros: + Dependen **versiones** concretas de **bibliotecas** y **frameworks**. + Dependen de servicios externos p.e: + Bases de datos + Bases de datos en memoria + Servicios específicos (¿dockerizados?) + Necesitamos tener instalado todo eso en el equipo ¿y si trabajamos en varios proyectos? --- ## Uso de Docker en sistemas de integración continua (CI) 1) El desarrollador sube cambios en el software a un repositorio 2) La modificación del repositorio dispara un proceso de construcción: + Descargar el software + Ejecutar pruebas + Construir una nueva imagen 3) Guardar la imagen recién construida en un repositorio de imágenes Note: (p.e. Dockerhub, Google Container Registry, Amazon ECR) --- ## Uso de Docker en Pre/Producción + Paso a producción de (`deploy`) la imagen desde el repositorio + La imagen se entrega al entorno de ejecución elegido: + Google Compute Engine // Amazon EC2 + Google App Engine // Amazon Fargate + Google Kubernetes // Amazon EKS + [Estrategia de despliegue de contenedores](#estrategias-de-despliegue-de-contenedores) elegida ---- ### Estrategias de despliegue de contenedores - `Recreate`: parar todos los contenedores antiguos y arrancar después los nuevos. - `Ramped`: ir parando contenedores antiguos y por cada uno parado arrancar uno nuevo. - `blue/gree`: arrancar todos los nuevos, conmutar el tráfico y detener los antiguos - `Canary`: arrancar uno nuevo, desviar parte del tráfico y si no hay fallos continuar - `A/B testing`: permite enviar parte del tráfico a una versión y parte a otra versión diferente Note: https://blog.container-solutions.com/kubernetes-deployment-strategies --- ## Arquitecturas con contenedores --- ### Caso de estudio: Wordpress ![](https://i.imgur.com/5vh8eiD.png) --- ## Fin

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully