liveBook · Manning

Routing

As explained in Learn Docker in a Month of Lunches, Second Edition

A Traefik router is a routing rule that matches an incoming request and selects a target service.

A Traefik router matches an incoming request and selects a target service. HTTP rules can match hostnames, paths, or path prefixes. section 20.4

A practical Traefik route connects:

  • An entrypoint, such as HTTP port 80 or HTTPS port 443. section 20.4
  • A router rule, such as Host(`whoami.local`). section 20.4
  • A service, which forwards traffic to the application container. section 20.4
  • Optional middleware, which can change paths or headers or enforce authentication. section 20.4

Route a container with labels

Enable Traefik and define the hostname rule on the service: traefik.enable=true and traefik.http.routers.whoami.rule=Host(`whoami.local`). Set the upstream port, start the Compose deployment, then verify with curl -i http://whoami.local.

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains the router-to-service mapping and label configuration, then verifies it with dashboard inspection and curl.
Examples
Uses the whoami application, hostname labels, a Traefik dashboard, curl checks, and scaled containers.
What it assumes
Assumes Docker Compose and containerized applications; introduces routing through a minimal labeled service configuration.
What you can do after
Apply it via Docker Compose and Traefik labels, then verify hostname routing and upstream responses with curl.
How it connects
Connects routers with entrypoints, services, middleware, Docker labels, HTTPS, load balancing, and sticky sessions.

Also explained in

Compare how 22 books explain routing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.