Docker: simplifying your application deployment

ContainersDockerDevOps

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

  • Running the container as root – create a non‑root user inside the image.
  • Skipping EXPOSE – makes it harder to see which ports are intended.
  • Using heavyweight base images – prefer Alpine‑based images to keep the size small.

Conclusion / Action plan

  • Install Docker on your machine.
  • Write a simple Dockerfile for one of your projects.
  • Add Docker commands to your CI pipeline.
  • After a successful run, explore docker‑compose for multi‑container setups.

Quick checklist

  • Install Docker Engine
  • Create a Dockerfile
  • Build the image
  • Run the container

Prompt Pack: Docker Quick‑Start

Write a step‑by‑step guide to install Docker on Ubuntu, create a simple Dockerfile, and run a container with a Node.js app. Include commands and explanations.