Skip to main content

Getting started

First, let's create a small working setup, that exposes the dashboard to traefik.<SITE> where site is the hostname given as an environment variable (e.g. traefik.example.com)

docker-compose.yml

version: "3"

services:
  traefik:
    image: traefik
    container_name: traefik
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./config/traefik.yml:/etc/traefik/traefik.yml
    labels:
      traefik.enable: true
      traefik.http.routers.traefik.service: api@internal
      traefik.http.routers.traefik.entrypoints: web
      traefik.http.routers.traefik.rule: Host(`traefik.${SITE}`)

config/traefik.yml

global:
  checkNewVersion: true
  sendAnonymousUsage: false
entryPoints:
  web:
    address: :80
api:
  dashboard: true
  insecure: true
providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

config/dynamic_config.yml is not yet needed

Traefik is now accepting http traffic on port 80. To route the traffic to an existing service, we can set labels inside the other apps docker-compose files (See Adding a service).