Back to Info Hub

Docker & Containers

Learn about containerization with Docker and related technologies.

Why Containers Changed Everything

Before containers, deploying software meant wrestling with environment inconsistencies - "it works on my machine" was a daily frustration. Docker solved this by packaging applications with everything they need to run, making deployments reproducible from a developer laptop to a production cluster. Today, containers are the standard unit of deployment for startups and enterprises alike.

At Wizard Tech Services, our web development projects are containerized by default, ensuring smooth handoffs and consistent environments. We also help teams containerize existing applications and set up orchestration as part of our automation and infrastructure services.

Containers vs. VMs

Virtual machines emulate entire operating systems and take minutes to boot. Containers share the host OS kernel and start in milliseconds, using a fraction of the memory. Use VMs when you need full OS isolation; use containers for application-level packaging and rapid scaling.

Dev-to-Prod Parity

Use Docker Compose locally and Kubernetes in production to keep your environments as similar as possible. The same Dockerfile builds the same image everywhere, eliminating configuration drift and "works on my machine" bugs.

Click below to see more information!
Select a category to explore detailed content

Back to Docker

Monitoring & Logging

Health checks, log aggregation, resource metrics, and alerting for your Docker containers.

Health Check in Docker Compose

Add a health check to ensure dependent services wait until a container is actually ready:

services:
  db:
    image: postgres:16-alpine
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 5

  api:
    build: ./api
    depends_on:
      db:
        condition: service_healthy
Docker Health Checks
Health Check

Built-in container health monitoring - define a test command in your Dockerfile or Compose file, and Docker automatically marks containers as healthy, unhealthy, or starting.

Key Features:

  • Built into Docker - no extra tools needed
  • HEALTHCHECK instruction in Dockerfile
  • healthcheck key in docker-compose.yml
  • depends_on with condition: service_healthy
Docker Logs
Logging

Docker captures stdout/stderr from every container. Use docker logs to view output, or configure logging drivers to forward logs to centralized systems like Loki or Elasticsearch.

Key Features:

  • docker logs -f for real-time log streaming
  • docker compose logs for multi-service logs
  • Configurable logging drivers (json-file, syslog, fluentd)
  • Log rotation with max-size and max-file options
Prometheus + Grafana
Metrics

The industry-standard observability stack - Prometheus scrapes metrics from containers and applications, Grafana visualizes them in customizable dashboards with alerting.

Key Features:

  • Prometheus collects time-series metrics
  • cAdvisor exports container resource metrics
  • Grafana dashboards with pre-built Docker templates
  • AlertManager for automated notifications
Grafana Loki
Logging

Log aggregation system designed for Docker and Kubernetes - lightweight alternative to Elasticsearch that integrates natively with Grafana for unified metrics and logs.

Key Features:

  • Lightweight log aggregation (indexes labels, not content)
  • Docker logging driver ships logs directly to Loki
  • Query logs with LogQL in Grafana
  • Pairs with Prometheus for unified observability
ctop / Lazydocker
Dashboard

Terminal-based monitoring tools - ctop provides a top-like interface for container metrics, Lazydocker adds a full TUI for managing containers, images, and volumes.

Key Features:

  • ctop: real-time CPU, memory, and network per container
  • Lazydocker: TUI for logs, stats, and management
  • No configuration needed - just run and go
  • Perfect for SSH sessions on remote servers
Uptime Kuma
Health Check

Self-hosted uptime monitoring with a clean UI - monitor HTTP, TCP, DNS, Docker containers, and more. Sends alerts via Discord, Slack, email, and 90+ notification services.

Key Features:

  • Monitor HTTP endpoints, TCP ports, DNS, and Docker containers
  • Status pages you can share with users
  • 90+ notification integrations (Discord, Slack, email, etc.)
  • Self-hosted with a single Docker container
Example: Full Monitoring Stack

A production-ready monitoring stack we use - Prometheus, Grafana, AlertManager, cAdvisor, Node Exporter, and Portainer on a shared network.

version: "3.9"

services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    restart: unless-stopped
    volumes:
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - ./prometheus/alert.rules.yml:/etc/prometheus/alert.rules.yml:ro
      - prometheus_data:/prometheus
    command:
      - "--config.file=/etc/prometheus/prometheus.yml"
      - "--storage.tsdb.path=/prometheus"
      - "--storage.tsdb.retention.time=30d"
      - "--web.enable-lifecycle"
    ports:
      - "9090:9090"
    networks:
      - monitoring

  alertmanager:
    image: prom/alertmanager:latest
    container_name: alertmanager
    restart: unless-stopped
    volumes:
      - ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
      - alertmanager_data:/alertmanager
    command:
      - "--config.file=/etc/alertmanager/alertmanager.yml"
    ports:
      - "9093:9093"
    networks:
      - monitoring

  cadvisor:
    image: gcr.io/cadvisor/cadvisor:latest
    container_name: cadvisor
    restart: unless-stopped
    ports:
      - "8080:8080"
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:ro
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
    networks:
      - monitoring

  node_exporter:
    image: prom/node-exporter:latest
    container_name: node_exporter
    restart: unless-stopped
    ports:
      - "9100:9100"
    command:
      - '--path.rootfs=/host'
    volumes:
      - '/:/host:ro,rslave'
    networks:
      - monitoring

  grafana:
    image: grafana/grafana-oss:latest
    container_name: grafana
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=changeme
    volumes:
      - grafana_data:/var/lib/grafana
    networks:
      - monitoring

  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: unless-stopped
    ports:
      - "9443:9443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    networks:
      - monitoring

networks:
  monitoring:

volumes:
  prometheus_data:
  alertmanager_data:
  grafana_data:
  portainer_data:

What Each Service Does

  • Prometheus - scrapes and stores time-series metrics (30-day retention)
  • AlertManager - routes alerts to Discord, Slack, or email
  • cAdvisor - exports container CPU, memory, and network metrics
  • Node Exporter - exports host-level system metrics
  • Grafana - visualizes everything in dashboards
  • Portainer - web UI for managing containers

Key Design Choices

  • • Shared monitoring network isolates traffic
  • --web.enable-lifecycle allows hot-reloading Prometheus config
  • • Named volumes persist data across container restarts
  • • Config files mounted :ro (read-only) for safety
  • • Import Grafana dashboard ID 193 for Docker monitoring