Hook

Docker lets you bundle your application and all its dependencies into a single isolated image. That means your code runs the same everywhere without the classic “it works on my machine” headaches.

Problem / Context

Before containers, deploying meant installing various software on each server, handling library versions, and dealing with incompatibilities. The result – environments diverge and releases break.

Why it matters

Containers give you stability, fast scaling, and simplify CI/CD pipelines. You save time on environment setup and reduce the risk of production bugs.

How to do it

  1. Install Docker Engine
    sudo apt‑update
    sudo apt‑install -y ca-certificates curl gnupg
    sudo mkdir -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    echo "deb [arch=$(dpkg --print-architecture) signed‑by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    sudo apt‑update
    sudo apt‑install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
  2. Verify the installation
    docker run --rm hello-world
  3. Create a Dockerfile for a simple Node.js app:
    FROM node:18-alpine
    WORKDIR /app
    COPY package*.json ./
    RUN npm ci --only=production
    COPY . .
    CMD ["node", "index.js"]
  4. Build the image
    docker build -t my‑app .
  5. Run the container
    docker run -d -p 3000:3000 --name my‑app‑c my‑app
    Your app is now reachable at http://localhost:3000.

Anti‑patterns

Conclusion / Action plan