DevOps & Cloud

Docker for Developers: From Zero to Containerized Applications

February 22, 2026 2 min read 5 views

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

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

# 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:

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:

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.

Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!