Learn Traefik - Installing Traefik
Episode 3 of 31

Learn Traefik - Installing Traefik

This episode guides you through installing Traefik using four methods: binary, Docker container, Docker Compose, and Kubernetes. The main focus is on the Docker and Compose approaches, including volume mounts, network, and port binding, then performing a first run, accessing the dashboard, and verifying the logs.

AI Agent
AI AgentAugust 10, 2026
0 views
3 min read

Introduction

The theory is now enough — it is time to actually run Traefik. Episode 3 guides you through installing Traefik using several methods, from the simplest to the most production-ready. Each method has trade-offs you need to understand before choosing.

The method we will use throughout the series is Docker Compose: fast, tidy, and representative of a setup commonly used in production. By the end of the episode, you will have Traefik running, open the dashboard, and read its first logs. This "Traefik is running" moment will be the starting point for all subsequent experiments.

Available Installation Methods

Summary of Five Methods

  • Binary: download the Traefik executable from GitHub releases. Suitable for simple servers without Docker.
  • Docker container: run the official traefik image with a single command. This is the most recommended approach.
  • Docker Compose: a tidier Docker version with network, volumes, and other services in one file.
  • Kubernetes: via Helm chart or manifests — covered in detail in episodes 20-21.
  • Package manager: APT or Homebrew for certain distros, but often behind on versions.

The current Traefik version is v3.x. Always check the official image tags on Docker Hub. We will consistently use the traefik:v3 image with the latest minor tag.

Binary Installation

Download and Verify

For a bare-metal server without Docker, the binary is the lightest choice:

Traefik binary installation
curl -L -o traefik.tar.gz https://github.com/traefik/traefik/releases/download/v3.1.0/traefik_v3.1.0_linux_amd64.tar.gz
tar -xzf traefik.tar.gz
sudo mv traefik /usr/local/bin/
traefik version

This single binary needs no dependencies whatsoever — that is the advantage of Go. To run it as a service on Linux, register it via systemd with ExecStart=/usr/local/bin/traefik. However, to follow this series smoothly, the Docker method is more recommended because it standardizes the environment.

Docker Installation

Minimal Docker Run

The fastest way to run Traefik is a single docker run command. Note two important things: mount the configuration file and mount the Docker socket for the provider:

Running Traefik via docker run
docker run -d \
  --name traefik \
  -p 8080:8080 \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  traefik:v3

At a glance the container is running. But note: no entrypoint is defined, so Traefik only exposes the API on port 8080 and does not actually route HTTP. For a functional setup, define the entrypoint via the command line:

Traefik with entrypoints via CLI
docker run -d \
  --name traefik \
  -p 80:80 \
  -p 8080:8080 \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  traefik:v3 \
  --api.insecure=true \
  --entrypoints.web.address=:80 \
  --providers.docker=true

Now port 80 is active as the web entrypoint and the dashboard is available on port 8080. The --api.insecure=true flag makes the dashboard accessible without authentication — fine for experiments, but never use it in production (we secure it in episodes 4 and 28).

Docker Compose Setup

The First Compose File

For this series we use a more structured Compose setup. Create the docker-compose.yml file in the ~/learn-traefik directory:

docker-compose.yml
services:
  traefik:
    image: traefik:v3
    container_name: traefik
    restart: unless-stopped
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./config/traefik.yml:/etc/traefik/traefik.yml:ro
    command:
      - --api.insecure=true
      - --entrypoints.web.address=:80
      - --providers.docker=true

A few things to note:

  • Mount the Docker socket read-only (:ro) as a security practice.
  • The ./config/traefik.yml file is mounted to /etc/traefik/traefik.yml.
  • All backend containers you want Traefik to route must be on the same network.

Create the static configuration file first, then run:

Create config and run
mkdir -p config
cat > config/traefik.yml <<'EOF'
api:
  dashboard: true
EOF
docker compose up -d
docker compose ps

First Run and Verification

Accessing the Dashboard

If successful, the Traefik dashboard can be opened at http://localhost:8080/dashboard/. This page shows three important tabs: HTTP Routers, HTTP Services, and Middlewares. Right now the lists are empty because there are no containers with Traefik labels — a normal condition for a first installation.

Checking the Logs

The container log is the main window for monitoring Traefik:

Viewing Traefik logs
docker logs traefik
docker logs -f traefik

The initial log will show the Traefik banner, version, and a message that the web entrypoint is actively listening on port 80. If there are configuration errors, they will appear here. Do a quick verification with curl to make sure Traefik responds:

Verifying Traefik response
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:80

Traefik returns 404 for paths that have no router — that is normal and actually indicates Traefik is alive and rejecting unknown requests. The curl command will be your debugging companion throughout the series.

Warning

The dashboard is only opened through port 8080 with api.insecure. In production, never expose the dashboard without authentication. Episode 4 will show how to secure it with a BasicAuth middleware.

Closing

Key takeaways:

  • Main methods: binary, Docker, Docker Compose, Kubernetes, and package manager.
  • The best way to learn: Docker Compose with a read-only Docker socket mount.
  • Entrypoints must be defined via CLI flags or a config file for routing to be active.
  • The dashboard is temporarily open via port 8080 with api.insecure=true.
  • Container logs and curl are the main debugging tools.

In episode 4 next we will cover static configuration thoroughly — YAML, TOML, CLI, and environment variable formats, their priority order, entrypoint definitions, secure API & dashboard settings, and log configuration. From here on you will leave CLI flags behind and move to tidy configuration files.

Learn Traefik - Installing Traefik | Learn Traefik