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.
YAML files define your entire application stack in one place. Learn how docker-compose.yml works, essential Compose commands, and see real-world examples including a modded Valheim game server and a Portainer deployment.
Two ways to run Docker - the Desktop GUI application for Mac/Windows or the command-line Engine on Linux. Compare features, resource usage, and learn which approach fits your workflow.
A web-based management UI for Docker - start, stop, and inspect containers from your browser. Deploy stacks from Compose files, manage multiple hosts, and use app templates for one-click deployments.
Health checks, log aggregation, resource metrics, and alerting for your containers. Covers Docker's built-in logging, Prometheus + Grafana stacks, Uptime Kuma, and terminal tools like ctop and Lazydocker.
Containers package your app, runtime, libraries, and config into one portable unit that runs identically anywhere. Covers the container lifecycle, volumes for persistent data, port mapping, and environment variable injection.
Docker images are built in layers via Dockerfile instructions. Write multi-stage builds for smaller images, tag versions, push to Docker Hub or GitHub Container Registry, and scan for vulnerabilities.
Monitoring & Logging
Health checks, log aggregation, resource metrics, and alerting for your Docker containers.
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_healthyBuilt-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 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
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
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
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
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
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
monitoringnetwork isolates traffic - •
--web.enable-lifecycleallows 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