Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/DevOps & cloud

Docker for Developers: From Zero to Containerized Applications

Master Docker fundamentals — images, containers, volumes, and networks — to ship consistent environments every time.

28 February 20261 min readDevOps & cloudاقرأ بالعربية

On this page

  1. Core Concepts
  2. Your First Dockerfile
  3. Essential Commands
  4. Volumes for Persistent Data
  5. Multi-Stage Builds

Docker eliminates the "works on my machine" problem by packaging applications with all their dependencies into standardized containers. As of 2025, over 20 million developers use Docker monthly.

Core Concepts

Images are read-only templates containing your app code, runtime, libraries, and system tools. Containers are running instances of images — lightweight, isolated processes sharing the host OS kernel. Unlike VMs, containers start in milliseconds and use minimal RAM.

Your First Dockerfile

dockerfile
FROM php:8.3-fpm-alpine
WORKDIR /var/www/html
RUN apk add --no-cache zip unzip curl \
    && docker-php-ext-install pdo pdo_mysql opcache
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY . .
RUN composer install --no-dev --optimize-autoloader
EXPOSE 9000
CMD ["php-fpm"]

Essential Commands

bash
# Build an image
docker build -t myapp:1.0 .

# Run a container
docker run -d -p 8080:9000 --name myapp myapp:1.0

# View running containers
docker ps

# View logs
docker logs -f myapp

# Enter a running container
docker exec -it myapp sh

Volumes for Persistent Data

Containers are ephemeral — when they stop, data inside is lost. Use volumes to persist databases:

bash
docker volume create mysql_data
docker run -d -v mysql_data:/var/lib/mysql mysql:8.0

Multi-Stage Builds

Reduce image size by separating build and runtime stages. A typical Node.js app drops from 1.2GB to under 150MB:

dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html

Multi-stage builds keep production images lean, secure, and fast to deploy.

All articles

Keep reading

  • CI/CD Pipelines with GitHub Actions: Automate Everything22 February 20261 min read
  • Clean Code Principles: Write Code That Humans Can Read22 February 20261 min read
  • Database Migration Strategies for Zero-Downtime Deployments22 February 20261 min read