Traefik

repository·master·Indexed 42 days ago

https://github.com/traefik/traefik-library-image

A modern HTTP reverse proxy and ingress controller that automatically and dynamically configures itself by integrating with infrastructure orchestrators like Docker, Kubernetes, and Swarm. Supports versions v2 and v3, featuring a Docker provider for service discovery and a web-based API dashboard.

Tokens
776
Snippets
3
Records
3
Agent score
3%

What's inside Traefik

  1. Quickstart Traefik v3 with Docker

    master

    To set up Traefik v3 using Docker, follow these steps:

    1. Create a configuration file named traefik.yml to enable the Docker provider and the insecure dashboard UI:
    # Docker configuration backend
    providers:
      docker:
        defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"
    
    # API and dashboard configuration
    api:
      insecure: true
    1. Run the Traefik v3 container. You must mount your traefik.yml and the Docker socket to allow Traefik to communicate with the Docker engine:
    docker run -d -p 8080:8080 -p 80:80 \
      -v $PWD/traefik.yml:/etc/traefik/traefik.yml \
      -v /var/run/docker.sock:/var/run/docker.sock \
      traefik:v3
    1. Deploy a backend service. For testing, you can run the traefik/whoami image:
    docker run -d --name test traefik/whoami
    1. Verify access. The service should now be reachable via the hostname generated by the defaultRule (e.g., test.docker.localhost):
    $ curl test.docker.localhost
    1. Access the Dashboard. Navigate to http://localhost:8080 in your browser to view routers, services, and middlewares.
  2. Quickstart Traefik v2 with Docker

    master

    To set up Traefik v2 using Docker, follow these steps:

    1. Create a configuration file named traefik.yml:
    # Docker configuration backend
    providers:
      docker:
        defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"
    
    # API and dashboard configuration
    api:
      insecure: true
    1. Run the Traefik v2 container. Mount your configuration and the Docker socket:
    docker run -d -p 8080:8080 -p 80:80 \
    -v $PWD/traefik.yml:/etc/traefik/traefik.yml \
    -v /var/run/docker.sock:/var/run/docker.sock \
    traefik:v2.11
    1. Deploy a backend service:
    docker run -d --name test traefik/whoami
    1. Verify access via the generated rule:
    $ curl test.docker.localhost
    1. Access the Dashboard at http://localhost:8080.
  3. Configure the Docker provider and API dashboard

    master

    Traefik can be configured via a traefik.yml file to automatically discover services and provide a web UI.

    Docker Provider

    Use the providers.docker section to enable Docker integration. Setting a defaultRule allows Traefik to automatically create a router for any container using a specific hostname pattern. In the example below, containers are accessed via [container-name].docker.localhost:

    providers:
      docker:
        defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"

    API and Dashboard

    To enable the web-based dashboard for inspecting routers, services, and middlewares, use the api section. Setting insecure: true allows access to the dashboard without additional authentication (typically on port 8080).

    providers:
      docker:
        defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"
    
    api:
      insecure: true