<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Docker on Commentary of Takao</title><link>https://takao.blog/es/categories/docker/</link><description>Recent content in Docker on Commentary of Takao</description><generator>Hugo -- gohugo.io</generator><language>es</language><copyright>Commentary of Takao</copyright><lastBuildDate>Sun, 12 Jul 2026 04:12:51 +0900</lastBuildDate><atom:link href="https://takao.blog/es/categories/docker/index.xml" rel="self" type="application/rss+xml"/><item><title>Docker Compose: Mejores prácticas de producción</title><link>https://takao.blog/es/web/docker-compose-production-best-practice/</link><pubDate>Mon, 20 Apr 2026 00:00:00 +0900</pubDate><guid>https://takao.blog/es/web/docker-compose-production-best-practice/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/docker-compose-production-best-practice-es.png" alt="Featured image of post Docker Compose: Mejores prácticas de producción" /&gt;&lt;p&gt;Más allá del Docker Compose básico, existen patrones probados para entornos de producción robustos.&lt;/p&gt;
&lt;h2 id="multi-stage-builds"&gt;Multi-stage builds
&lt;/h2&gt;&lt;p&gt;Compila en una etapa, ejecuta en otra más ligera. Reduce significativamente el tamaño de la imagen final y la superficie de ataque.&lt;/p&gt;
&lt;h2 id="healthchecks"&gt;Healthchecks
&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;healthcheck&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;test&lt;/span&gt;: [&lt;span style="color:#e6db74"&gt;&amp;#34;CMD&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;curl&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;-f&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;http://localhost&amp;#34;&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;interval&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;30s&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;retries&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Docker reinicia servicios no saludables automáticamente.&lt;/p&gt;
&lt;h2 id="logging"&gt;Logging
&lt;/h2&gt;&lt;p&gt;Configura drivers de logging (&lt;code&gt;json-file&lt;/code&gt;, &lt;code&gt;fluentd&lt;/code&gt;, &lt;code&gt;awslogs&lt;/code&gt;). Rotación de logs: &lt;code&gt;max-size: 10m&lt;/code&gt;, &lt;code&gt;max-file: 3&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="seguridad-de-red"&gt;Seguridad de red
&lt;/h2&gt;&lt;p&gt;Redes separadas para frontend, backend y base de datos. Solo expone puertos al host cuando sea necesario. Usa redes externas para servicios compartidos.&lt;/p&gt;</description></item><item><title>Caché de build en Docker: Acelerar compilaciones</title><link>https://takao.blog/es/web/docker-build-caches-speedup/</link><pubDate>Sat, 20 Sep 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/es/web/docker-build-caches-speedup/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/docker-build-caches-speedup-es.png" alt="Featured image of post Caché de build en Docker: Acelerar compilaciones" /&gt;&lt;p&gt;Docker aprovecha la caché de capas para acelerar builds. Entender el orden de las capas y la invalidación de caché es clave para builds rápidos.&lt;/p&gt;
&lt;h2 id="orden-de-capas"&gt;Orden de capas
&lt;/h2&gt;&lt;p&gt;Coloca las capas que cambian con menos frecuencia al inicio: dependencias del sistema, luego dependencias de la aplicación, luego código fuente.&lt;/p&gt;
&lt;h2 id="copy-vs-add"&gt;COPY vs ADD
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;COPY&lt;/code&gt; invalida la caché si el contenido del archivo fuente cambia. Usa &lt;code&gt;.dockerignore&lt;/code&gt; para excluir archivos innecesarios (node_modules, .git).&lt;/p&gt;</description></item><item><title>Multi-stage builds de Docker: Imágenes más ligeras</title><link>https://takao.blog/es/web/docker-multi-stage-build-reduction/</link><pubDate>Thu, 20 Mar 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/es/web/docker-multi-stage-build-reduction/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/docker-multi-stage-build-reduction-es.png" alt="Featured image of post Multi-stage builds de Docker: Imágenes más ligeras" /&gt;&lt;p&gt;Multi-stage builds usan múltiples instrucciones FROM en un solo Dockerfile. Cada etapa puede usar una base diferente, copiando solo los artefactos necesarios a la etapa final.&lt;/p&gt;
&lt;h2 id="ejemplo-nodejs"&gt;Ejemplo Node.js
&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-dockerfile" data-lang="dockerfile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;FROM&lt;/span&gt; &lt;span style="color:#e6db74"&gt;node:20&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;AS&lt;/span&gt; &lt;span style="color:#e6db74"&gt;build&lt;/span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;WORKDIR&lt;/span&gt; &lt;span style="color:#e6db74"&gt;/app&lt;/span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;COPY&lt;/span&gt; package*.json .&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;RUN&lt;/span&gt; npm ci&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;COPY&lt;/span&gt; . .&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;RUN&lt;/span&gt; npm run build&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;FROM&lt;/span&gt; &lt;span style="color:#e6db74"&gt;node:20-slim&lt;/span&gt;&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;COPY&lt;/span&gt; --from&lt;span style="color:#f92672"&gt;=&lt;/span&gt;build /app/dist ./dist&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;CMD&lt;/span&gt; [&lt;span style="color:#e6db74"&gt;&amp;#34;node&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;dist/index.js&amp;#34;&lt;/span&gt;]&lt;span style="color:#960050;background-color:#1e0010"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="beneficios"&gt;Beneficios
&lt;/h2&gt;&lt;p&gt;Reduce la imagen final de ~1GB a ~150MB. Elimina herramientas de compilación, dependencias de desarrollo y archivos temporales.&lt;/p&gt;</description></item><item><title>Docker Compose en producción</title><link>https://takao.blog/es/web/docker-compose-production/</link><pubDate>Tue, 12 Nov 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/es/web/docker-compose-production/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/docker-compose-production-es.png" alt="Featured image of post Docker Compose en producción" /&gt;&lt;p&gt;Docker Compose no es solo para desarrollo. Con configuraciones adecuadas puede orquestar servicios en producción para despliegues pequeños y medianos.&lt;/p&gt;
&lt;h2 id="diferencias-desarrollo-vs-producción"&gt;Diferencias desarrollo vs producción
&lt;/h2&gt;&lt;p&gt;Usa múltiples archivos: &lt;code&gt;docker-compose.yml&lt;/code&gt; base, &lt;code&gt;docker-compose.override.yml&lt;/code&gt; para desarrollo, &lt;code&gt;docker-compose.prod.yml&lt;/code&gt; para producción.&lt;/p&gt;
&lt;h2 id="seguridad"&gt;Seguridad
&lt;/h2&gt;&lt;p&gt;No expongas puertos innecesarios. Usa redes internas para servicios. Variables de entorno via archivos &lt;code&gt;.env&lt;/code&gt; o secretos de Docker.&lt;/p&gt;
&lt;h2 id="persistencia-de-datos"&gt;Persistencia de datos
&lt;/h2&gt;&lt;p&gt;Volúmenes nombrados en lugar de bind mounts. Backups periódicos. Políticas de reinicio: &lt;code&gt;restart: unless-stopped&lt;/code&gt; o &lt;code&gt;restart: always&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Redes en Docker: Comunicación entre contenedores</title><link>https://takao.blog/es/web/docker-networking/</link><pubDate>Tue, 27 Aug 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/es/web/docker-networking/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/docker-networking-es.png" alt="Featured image of post Redes en Docker: Comunicación entre contenedores" /&gt;&lt;p&gt;Docker proporciona varios modos de red para la comunicación entre contenedores y con el exterior. Elegir el correcto es fundamental para la seguridad y el rendimiento.&lt;/p&gt;
&lt;h2 id="tipos-de-red"&gt;Tipos de red
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;bridge&lt;/code&gt; (default): red privada por host, comunicación entre contenedores via IP/nombre. &lt;code&gt;host&lt;/code&gt;: comparte la red del host. &lt;code&gt;overlay&lt;/code&gt;: múltiples hosts (Swarm). &lt;code&gt;none&lt;/code&gt;: sin red.&lt;/p&gt;
&lt;h2 id="dns-interno"&gt;DNS interno
&lt;/h2&gt;&lt;p&gt;Docker tiene DNS interno. Los contenedores en la misma red bridge personalizada se resuelven por nombre de contenedor. No es necesario conocer IPs.&lt;/p&gt;</description></item><item><title>Seguridad en contenedores: Mejores prácticas</title><link>https://takao.blog/es/web/container-security/</link><pubDate>Tue, 16 Jul 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/es/web/container-security/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/container-security-es.png" alt="Featured image of post Seguridad en contenedores: Mejores prácticas" /&gt;&lt;p&gt;La seguridad en contenedores abarca desde la imagen base hasta la configuración de runtime. Un contenedor inseguro compromete todo el host.&lt;/p&gt;
&lt;h2 id="imágenes-base"&gt;Imágenes base
&lt;/h2&gt;&lt;p&gt;Usa imágenes oficiales y actualizadas. Prefiere &lt;code&gt;-slim&lt;/code&gt;, &lt;code&gt;-alpine&lt;/code&gt; o distroless. Escanea vulnerabilidades con &lt;code&gt;docker scout&lt;/code&gt; o &lt;code&gt;trivy&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="principio-de-mínimos-privilegios"&gt;Principio de mínimos privilegios
&lt;/h2&gt;&lt;p&gt;No ejecutes como root: &lt;code&gt;USER nobody&lt;/code&gt; en Dockerfile. Capacidades de Linux mínimas: &lt;code&gt;--cap-drop ALL --cap-add NEEDED&lt;/code&gt;. Modo de solo lectura: &lt;code&gt;--read-only&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="secrets-y-variables"&gt;Secrets y variables
&lt;/h2&gt;&lt;p&gt;Nunca incluyas secretos en la imagen. Usa &lt;code&gt;--secret&lt;/code&gt; de BuildKit para construir, y variables de entorno o montajes de secretos para ejecutar.&lt;/p&gt;</description></item><item><title>Health Checks en Docker: Monitoreo de servicios</title><link>https://takao.blog/es/web/docker-health-checks/</link><pubDate>Mon, 25 Dec 2023 00:00:00 +0900</pubDate><guid>https://takao.blog/es/web/docker-health-checks/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/docker-health-checks-es.png" alt="Featured image of post Health Checks en Docker: Monitoreo de servicios" /&gt;&lt;p&gt;Los health checks de Docker permiten que el engine monitoree el estado de los contenedores y tome acciones automáticas (reinicios, notificaciones).&lt;/p&gt;
&lt;h2 id="sintaxis"&gt;Sintaxis
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD curl -f http://localhost || exit 1&lt;/code&gt; en Dockerfile, o &lt;code&gt;healthcheck&lt;/code&gt; en docker-compose.yml.&lt;/p&gt;
&lt;h2 id="protocolos"&gt;Protocolos
&lt;/h2&gt;&lt;p&gt;HTTP: &lt;code&gt;curl -f http://localhost/health&lt;/code&gt;. TCP: &lt;code&gt;nc -z localhost 3306&lt;/code&gt;. Script personalizado para lógica compleja.&lt;/p&gt;
&lt;h2 id="integración-con-orquestadores"&gt;Integración con orquestadores
&lt;/h2&gt;&lt;p&gt;Docker Compose reinicia contenedores no saludables. Swarm y Kubernetes usan health checks para reemplazar instancias fallidas.&lt;/p&gt;</description></item></channel></rss>