De Docker a Kubernetes: De local a la nube

Guía práctica para empaquetar una app Node.js con Docker, subirla a Docker Hub y desplegarla y escalarla con Kubernetes, con enfoque en soluciones empresariales de Q2BSTUDIO.

18 sept 2025 • 4 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Docker y Kubernetes suelen mencionarse juntos en el desarrollo moderno, pero resuelven problemas distintos: Docker facilita empaquetar aplicaciones en contenedores y Kubernetes orquesta esos contenedores a escala, en múltiples servidores, con automatización y tolerancia a fallos. En este artículo práctico revisado y traducido explico paso a paso cómo crear una app sencilla con Docker, subir la imagen a Docker Hub y desplegarla y escalarla en Kubernetes, además de comentar cómo estas tecnologías encajan con los servicios que ofrece Q2BSTUDIO en desarrollo de soluciones empresariales.

Requisitos previos: tener instalado Node.js reciente, Docker Desktop o Docker Engine, kubectl y un cluster Kubernetes local como Minikube o el propio Kubernetes de Docker Desktop. Verifica con los comandos node -v; docker --version; kubectl version --client. También necesitarás una cuenta gratuita en Docker Hub.

Crear una aplicación Node.js simple. En un terminal crea el proyecto: mkdir docker-k8s-demo y cd docker-k8s-demo. Inicializa npm con npm init -y. Crea un archivo app.js con este contenido básico: const http = require('http'); const port = 3000; const requestHandler = (req, res) => { res.end('Hola desde Docker y Kubernetes!'); }; const server = http.createServer(requestHandler); server.listen(port, () => { console.log('Servidor en el puerto ' + port); }); Este script expone una respuesta HTTP sencilla en el puerto 3000.

Escribir un Dockerfile. En la raíz del proyecto crea un archivo Dockerfile con estas instrucciones: FROM node:18-alpine WORKDIR /usr/src/app COPY package*.json ./ COPY app.js ./ RUN npm install EXPOSE 3000 CMD node app.js Construye la imagen con docker build -t myapp:1.0 . y ejecútala localmente con docker run -p 3000:3000 myapp:1.0. Accede a https://localhost:3000 para comprobar que responde Hola desde Docker y Kubernetes.

Subir la imagen a Docker Hub. Inicia sesión con docker login. Etiqueta la imagen con docker tag myapp:1.0 tu-usuario/myapp:1.0 y súbela con docker push tu-usuario/myapp:1.0. Kubernetes necesitará poder descargar la imagen desde un registro público o privado.

Desplegar en Kubernetes. Crea un archivo deployment.yaml con una Deployment de 3 réplicas y un Service tipo LoadBalancer. Ejemplo simplificado: apiVersion: apps/v1 kind: Deployment metadata: name: myapp-deployment spec: replicas: 3 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: myapp image: tu-usuario/myapp:1.0 ports: - containerPort: 3000 --- apiVersion: v1 kind: Service metadata: name: myapp-service spec: selector: app: myapp ports: - protocol: TCP port: 80 targetPort: 3000 type: LoadBalancer Aplica la definición con kubectl apply -f deployment.yaml y comprueba las pods con kubectl get pods. Para ver el servicio en Minikube usa minikube service myapp-service; en Docker Desktop o en la nube obtendrás una IP o un LoadBalancer.

Escalar la aplicación. Kubernetes facilita aumentar o reducir réplicas con un solo comando: kubectl scale deployment myapp-deployment --replicas=5. Kubernetes creará automáticamente los pods adicionales y distribuirá la carga. Este patrón build with Docker y deploy with Kubernetes es la base de las aplicaciones cloud native: Docker garantiza consistencia entre entornos y Kubernetes aporta fiabilidad y gestión automatizada en producción.

Cómo encaja esto con Q2BSTUDIO. En Q2BSTUDIO desarrollamos aplicaciones a medida y software a medida que pueden empaquetarse con Docker y desplegarse en Kubernetes para entornos productivos. Además ofrecemos servicios cloud aws y azure para ejecutar clusters y gestionar despliegues en la nube, integrando prácticas de seguridad y alta disponibilidad. Nuestro equipo también trabaja en soluciones de inteligencia artificial, ia para empresas y agentes IA para automatizar tareas y mejorar procesos, y en servicios de inteligencia de negocio y power bi para transformar datos en decisiones.

Seguridad y buenas prácticas. Antes de exponer servicios en producción conviene implementar políticas de seguridad, escaneo de imágenes, gestión de secretos y pruebas de pentesting. En Q2BSTUDIO realizamos auditorías y servicios de ciberseguridad y hardening y pruebas de pentesting como parte de un ciclo DevSecOps.

Conclusión. Aprender a construir con Docker y orquestar con Kubernetes abre la puerta a arquitecturas escalables y reproducibles, fundamentales para proyectos de software a medida, soluciones con inteligencia artificial o plataformas en la nube. Si te interesa que te ayudemos a portar tu aplicación a contenedores, desplegarla en AWS o Azure, diseñar agentes IA o implantar cuadros de mando con Power BI, en Q2BSTUDIO podemos acompañarte de la idea al despliegue.

Contacto. Si quieres profundizar o colaborar en artículos técnicos, documentación o desarrollos a medida, ponte en contacto con nosotros y trabajemos juntos para adaptar estas tecnologías a tus necesidades empresariales.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat