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 Demystified: A Beginner's Guide to Containers in 2026

    By Huzi

    Everyone says learn Docker; almost nobody shows you the first hour. This guide is that hour: install, first container, your own image, then a compose file that links two services. No architecture lectures — if you can open a terminal, you will finish before your chai does.

    Install it and prove it works

    Docker Desktop for Windows and macOS, the apt package for Ubuntu. Then run the two commands that matter:

    docker --version
    docker run hello-world
    

    That second command pulled a tiny image from Docker Hub, created a container from it, ran it, and exited. That is the entire model: an image is the frozen recipe, a container is one run of it.

    Your first real container

    docker run -d -p 8080:80 --name my-site nginx
    

    Open localhost:8080 in your browser and you are looking at a page served from inside that container. The flags: -d detaches it into the background, -p maps port 8080 on your laptop to port 80 inside, and --name saves you from copying random IDs everywhere. Daily life is three commands after that — docker ps to see what runs, docker logs -f my-site to follow output, docker stop my-site to end it.

    Package your own app

    A Dockerfile is four ideas: a base image, a working directory, your files, a start command.

    FROM node:22-alpine
    WORKDIR /app
    COPY package*.json ./
    RUN npm ci --omit=dev
    COPY . .
    USER node
    CMD ["node", "server.js"]
    

    Build it and run it:

    docker build -t my-app .
    docker run -p 3000:3000 my-app
    

    Adopt two habits on day one. Pin the base image (node:22-alpine, never latest) and let the app run as the node user instead of root. Add a .dockerignore listing node_modules, .git and .env so builds stay quick and secrets stay out of the image.

    Two containers, one file

    Real apps need a database. Create compose.yaml:

    services:
      app:
        build: .
        ports:
          - "3000:3000"
        depends_on:
          - db
      db:
        image: postgres:17-alpine
        environment:
          POSTGRES_PASSWORD: secret
    

    Then docker compose up --build starts the pair with the app waiting on the database, and docker compose down cleans it all up. Compose hands a teammate your entire stack as one file instead of a wiki page of setup steps — and when leftover images pile up over the months, docker system prune reclaims the disk.

    That is the whole foundation: images, containers, one Dockerfile, one compose file. The deeper topics — multi-stage builds, health checks, image scanning — all make sense on top of these four steps.

    Every time an image lands in seconds, I think of the ships that cannot berth: the same container traffic that moves the world's goods is being used to choke Gaza, where aid waits at crossings while families count sacks of flour. Supply chains work when the world decides they should; may that decision reach the people still waiting.

    Your first container ran within minutes, and your first trip abroad should feel like that too — we make sure of it at HTG Travels, our licensed Sialkot agency. Dubai and Gulf tickets for first-time flyers, visa files checked field by field, and a human on the phone who explains each step instead of forwarding you a form.

    Advertisements


    You Might Also Like

    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 3500

    Aneela Black Embroidered Velvet Dress – Unstitched Luxury Wedding & Party Outfit with Rich Embellishments

    Aneela Black Embroidered Velvet Dress – Unstitched Luxury Wedding & Party Outfit with Rich Embellishments

    PKR 9999

    Heavy Embroidered Velvet Party Wear Suit 2026 | Printed Jamawar Trouser

    Heavy Embroidered Velvet Party Wear Suit 2026 | Printed Jamawar Trouser

    PKR 5800

    Men’s Unstitched Wash n Wear Shalwar Kameez Suit – Premium Fabric | Summer Collection Pakistan

    Men’s Unstitched Wash n Wear Shalwar Kameez Suit – Premium Fabric | Summer Collection Pakistan

    PKR 2600

    Elegant All-Over Print & Embroidered 3-Piece Lawn Suit 2026 | Chiffon Dupatta (Casual)

    Elegant All-Over Print & Embroidered 3-Piece Lawn Suit 2026 | Chiffon Dupatta (Casual)

    PKR 5500

    Advertisements


    Related Posts

    Programming
    Docker for Developers: The 2026 Edition
    What containers actually are, a multi-stage Python Dockerfile worth copying with BuildKit cache mounts and a non-root user, and Compose for the app-plus-database stack.

    By Huzi

    Read More
    Programming
    Demystifying REST APIs: A Beginner's Guide (2026)
    Resources with URLs, HTTP verbs as actions, status codes as the contract, and where REST sits next to GraphQL and gRPC in a 2026 backend.

    By Huzi

    Read More
    Programming
    The Ultimate Beginner's Guide to Building a Website with Cloudflare Pages (2026)
    From an empty folder to a live site: git push, connect the repo in the dashboard, Pages Functions with D1 bindings, and the two fixes every beginner eventually needs.

    By Huzi

    Read More
    Programming
    The Beginner's Guide to React: Building the Modern Web (2026)
    The component mental model, one-way props, the server/client split that defines modern React, and the scaffolding commands to start a real project today.

    By Huzi

    Read More
    Programming
    A Beginner's Guide to React Hooks: Mastering Modern React (2026)
    useState, useEffect, the React 19 form hooks, and the two rules that keep hooks from breaking — each with a runnable snippet.

    By Huzi

    Read More
    Programming
    Rust for JavaScript Developers 2026: The Complete Problem-Solving Guide
    Ownership, borrowing, Option, Result and the ? operator, Tokio and a first Axum API — Rust explained through the JavaScript habits you already have.

    By Huzi

    Read More