This scenario uses Docker Compose to define the architecture, and Docker Container labels to define the metadata and rules for routing.
Create Traefik Container
Start creating the Docker Compose file by first defining the load balancer.
traefik: image: traefik command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG ports: - "80:80" - "8080:8080" - "443:443" volumes: - /var/run/docker.sock:/var/run/docker.sock - /dev/null:/traefik.toml
The Load Balancer is configured to list on ports 80 and 443 for HTTP traffic. It also has a web dashboard available on port 8080. The dashboard should be considered internal and restricted by a firewall.
The use of docker.sock allows traefik to listen to the Docker Host Daemon Events and reconfigure itself when containers are started/stopped. It also uses this to find additional metadata about the containers, such as which domain name they process.