Hawiyat

Docker Compose Domain

Docker Compose Domain Management System

Introduction

Docker Compose is a powerful tool for defining and running multi-container Docker applications. When integrated with Hawiyat's domain management system, it provides a robust foundation for deploying scalable, accessible applications. This comprehensive guide will walk you through the process of configuring domains for your Docker Compose applications, ensuring secure and efficient container networking.

System Architecture Overview

Before diving into the configuration process, it's important to understand how the different components work together:

  1. Docker Compose Layer

    • Manages container orchestration
    • Handles service definitions
    • Controls networking between containers
    • Manages container lifecycle
  2. Traefik Integration

    • Provides reverse proxy functionality
    • Handles SSL/TLS termination
    • Manages routing rules
    • Enables automatic certificate management
  3. Hawiyat Network Layer

    • Facilitates container communication
    • Manages service discovery
    • Handles load balancing
    • Ensures secure internal networking

DNS Configuration Process

Understanding DNS Architecture

The Domain Name System (DNS) acts as the foundation for making your Docker services accessible. It translates human-readable domain names into IP addresses that computers can understand. In the context of Docker Compose applications, proper DNS configuration is crucial for:

  • Service accessibility
  • Load balancing
  • SSL/TLS certificate management
  • High availability

DNS Record Setup

Configure your domain's DNS settings with the following specifications:

  1. Record Configuration
    Type: A Record
    Name: app (for app.yourdomain.com)
    Value: Your server's IP (e.g., 1.2.3.4)
    TTL: 3600 (recommended)

DNS propagation can take between 1-48 hours depending on your provider and global DNS cache settings. Plan your deployment accordingly.

Docker Compose Integration

Network Architecture

The Hawiyat platform utilizes a sophisticated networking setup that enables seamless communication between containers while maintaining security and isolation. This is achieved through the hawiyat-network, a custom Docker network that provides:

  • Service discovery
  • Internal DNS resolution
  • Load balancing
  • Network isolation
  • Security boundaries

Basic Configuration

To integrate your Docker Compose services with the Hawiyat platform, your configuration needs to address two main aspects:

Network Integration

The hawiyat-network serves as the backbone of container communication. Here's how to properly configure it:

services:
  app:
    image: nextjs-app
    networks:
      - hawiyat-network    # Enables communication with Hawiyat services
    ports:
      - "3000"            # Expose application port
 
networks:
  hawiyat-network:
    external: true        # Uses existing Hawiyat network

This configuration provides:

  • Seamless service discovery
  • Automatic DNS resolution
  • Internal load balancing
  • Network security isolation

Traefik Configuration

Traefik serves as the edge router, managing incoming traffic and SSL certificates. The configuration varies based on your security requirements:

Standard Configuration (Cloudflare Default)

When using Cloudflare's default configuration, implement basic HTTP routing:

labels:
  - "traefik.http.routers.<unique-name>.entrypoints=web"
Secure Configuration (Let's Encrypt / Cloudflare Full Strict)

For enhanced security with automatic SSL certificate management:

labels:
  - "traefik.http.routers.<unique-name>.entrypoints=websecure"
  - "traefik.http.routers.<unique-name>.tls.certResolver=letsencrypt"

Complete Configuration Example

Here's a comprehensive example that implements all security features:

services:
  app:
    image: nextjs-app
    networks:
      - hawiyat-network
    ports:
      - "3000"
    labels:
      - "traefik.enable=true"                                                    # Enable Traefik for this service
      - "traefik.http.routers.<unique-name>.entrypoints=websecure"              # Use HTTPS endpoint
      - "traefik.http.routers.<unique-name>.tls.certResolver=letsencrypt"       # Automatic SSL certificates
      - "traefik.http.routers.<unique-name>.rule=Host(`app.yourdomain.com`)"    # Domain routing rule
      - "traefik.http.services.<unique-name>.loadbalancer.server.port=3000"     # Container port
networks:
  hawiyat-network:
    external: true

Advanced Configuration

SSL/TLS Management

The platform offers flexible SSL/TLS configuration options:

  1. Automatic Certificate Management

    • Let's Encrypt integration
    • Automatic renewal
    • Zero-downtime updates
    • Wild card certificate support
  2. Custom Certificate Integration

    • Support for existing certificates
    • Custom CA certificates
    • Multiple certificate chains
    • SNI support

Load Balancing

Traefik provides sophisticated load balancing capabilities:

  1. Algorithms

    • Round Robin (default)
    • Weighted Round Robin
    • Dynamic Round Robin
  2. Health Checks

    • Path-based monitoring
    • Custom health check endpoints
    • Configurable intervals
    • Failure thresholds

Security Best Practices

  1. Network Security

    • Use secure endpoints
    • Implement rate limiting
    • Enable TLS 1.3
    • Configure security headers
  2. Certificate Management

    • Regular certificate rotation
    • Automated renewal monitoring
    • Certificate transparency logging
    • Key storage security

Always use HTTPS in production environments. The 'web' endpoint should only be used in development or when behind a secure proxy.

Example Configurations

Basic Development Setup

For detailed examples and starter templates, refer to our Docker Compose Quickstart documentation.

Monitoring and Maintenance

  1. Health Monitoring

    • Container status
    • Certificate expiration
    • Network connectivity
    • Service response times
  2. Performance Optimization

    • Cache configuration
    • Connection pooling
    • Resource allocation
    • Network optimization

Regular monitoring of your Docker Compose services ensures optimal performance and early detection of potential issues.

On this page