Huzi Blogs
BlogCategories
BlogCategories
Disclaimer & Data Privacy Policy
Project by huzi.pk

© 2026 blogs.huzi.pk. All Rights Reserved.

    Back to all posts
    Programming

    Docker for Developers: The 2026 Edition

    By Huzi

    Every developer knows the ritual: code runs on your laptop, dies on the server. The Python version differs, a system library is missing, and nobody can reproduce the failure on purpose. Docker ends the ritual by shipping the environment with the code — one artifact that runs the same way anywhere.

    Containers, not virtual machines

    A container packages the app and its dependencies and shares the host kernel; a VM virtualizes hardware and carries a whole guest operating system. That is the difference between megabytes and gigabytes, seconds and minutes of startup. One host runs dozens of containers comfortably, and Docker now even runs WebAssembly images for edge workloads smaller still.

    Keep the two words straight and the rest follows: the image is the blueprint, versioned in layers; the container is one running instance of it. Registries are where images travel between machines.

    A Dockerfile worth copying

    Multi-stage builds install dependencies in one stage and copy only the result into a slim runtime. Cache mounts stop pip from re-downloading the world on every build, a non-root user is now a hard requirement in Kubernetes, and gunicorn replaces the Flask dev server for production:

    # syntax=docker/dockerfile:1.7
    FROM python:3.13-slim AS builder
    WORKDIR /app
    COPY requirements.txt .
    RUN --mount=type=cache,target=/root/.cache/pip \
        pip install --user --no-cache-dir -r requirements.txt
    
    FROM python:3.13-slim
    WORKDIR /app
    COPY --from=builder /root/.local /root/.local
    COPY . .
    RUN useradd -m appuser
    USER appuser
    ENV PATH=/root/.local/bin:$PATH
    EXPOSE 8000
    CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app:app"]
    

    Build, run, ship

    docker build -t my-app .
    docker run -p 8000:8000 my-app
    docker push ghcr.io/you/my-app:1.0
    

    The image on a colleague's machine behaves like yours because it is yours — every layer, byte for byte, on Docker Hub, GHCR or ECR.

    Compose for the whole stack

    Real apps need a database, and Compose declares the pair in one file. The healthcheck with pg_isready plus depends_on means your web container waits for a genuinely ready database, not merely a started one:

    services:
      web:
        build: .
        ports:
          - "8000:8000"
        environment:
          DATABASE_URL: postgres://app:secret@db:5432/app
        depends_on:
          db:
            condition: service_healthy
      db:
        image: postgres:17-alpine
        environment:
          POSTGRES_PASSWORD: secret
        healthcheck:
          test: ["CMD-SHELL", "pg_isready -U app"]
          interval: 5s
    

    Run docker compose up --build and the stack is live in seconds.

    Why teams keep it: consistency from laptop to CI to production, isolation between apps with conflicting dependencies, and portability to ECS, Cloud Run or any Kubernetes cluster. The learning curve is one honest afternoon; the payoff is never debugging an environment mismatch again.

    Portability is a feature in software and a wound in life. Gaza's families carry entire households in whatever transport remains and rebuild a routine wherever they land — a resilience no one should have needed. Their steadfastness deserves more than admiration from a distance.

    First deploys have checklists, and so do first trips abroad. We handle first-timers gently at HTG Travels — Dubai and Gulf ticketing, the visa, the airport walkthrough, what goes in the carry-on. You bring the nerves; we bring the runbook, and nobody travels alone.

    Advertisements


    You Might Also Like

    Maroon Raw Silk Party Dress – Emb Sleeves & Bottoms, Organza Dupatta

    Maroon Raw Silk Party Dress – Emb Sleeves & Bottoms, Organza Dupatta

    PKR 5500

    Gray Hijabi-Girl Faux-Leather Handbag – Twist Lock, Long Strap, 11×14

    Gray Hijabi-Girl Faux-Leather Handbag – Twist Lock, Long Strap, 11×14

    PKR 2800

    Bottle-Green Velvet Unstitched Winter Dress – Handwork, Pearl & Zari

    Bottle-Green Velvet Unstitched Winter Dress – Handwork, Pearl & Zari

    PKR 8200

    Heavy Embroidered Formal Chiffon Suit 2026 | Silk Gharara Trouser

    Heavy Embroidered Formal Chiffon Suit 2026 | Silk Gharara Trouser

    PKR 7770

    IB Swiss Fashion Men’s Unstitched Shalwar Kameez – Premium Soft Egyptian Cotton Fabric | Summer Wear Pakistan

    IB Swiss Fashion Men’s Unstitched Shalwar Kameez – Premium Soft Egyptian Cotton Fabric | Summer Wear Pakistan

    PKR 3000

    Advertisements


    Related Posts

    Programming
    Docker Demystified: A Beginner's Guide to Containers in 2026
    The first hour of Docker, hands-on: install it, run your first container, write your first Dockerfile, and link two services with one compose file.

    By Huzi

    Read More
    Programming
    Python Async/Await Deep Dive 2026: The Complete Problem-Solving Guide
    asyncio.run, gather, TaskGroup, httpx sessions and the blocking-call escape hatch — the 2026 Python async patterns that actually ship, with copy-paste code.

    By Huzi

    Read More
    Programming
    The Developer's Toolkit: Top 10 VS Code Extensions for 2026
    Ten VS Code extensions that earn their keep in 2026, from Copilot and Cursor to Prettier, ESLint, GitLens and Thunder Client, plus the settings that wire them together.

    By Huzi

    Read More
    Programming
    The Static Renaissance: Why Pre-Rendered Webs are Winning in 2026
    Build-time rendering, CDN edges, on-demand revalidation and Astro Server Islands — why static-first is the 2026 default for fast, secure, cheap sites.

    By Huzi

    Read More
    Programming
    10 JavaScript Tricks That Will Save You Hours of Coding in 2026
    Ten patterns that pay rent: optional chaining, nullish coalescing, Object.groupBy, Set algebra, structuredClone, Array.fromAsync and the rest of the modern toolkit.

    By Huzi

    Read More
    Programming
    The Modern Script: Top 5 ES2024+ Features You Must Use in 2026
    From let and const to arrow functions, destructuring, spread and template literals, plus the ES2024 arrivals — Object.groupBy, Set algebra and top-level await.

    By Huzi

    Read More