Portainer Templates logo

Portainer Templates

Traefik (stack) Traefik (stack)

WebNetwork

The Cloud Native Application Proxy. Source: https://github.com/traefik/traefik

Image details

Pulls: 3.5B
Architecture: amd64, arm/v6, ppc64le, s390x, riscv64, arm64/v8
Image size: 167 MB
Latest: 3.6.25-nanoserver-ltsc2022
User: library
Created: Apr 06, 2016
Updated: 3 days ago
Status: active

Source details

Stars: 64.4k
Forks: 6k
Language: Go
License: MIT
Updated: 2 days ago
Website: traefik.io/

Configuration

Type
Compose
Platform
linux
Image
traefik:v3
Command
--api.insecure=true --providers.docker
Ports
80:808080:8080
Volumes
/var/run/docker.sock : /var/run/docker.sock
Restart
unless-stopped
Source

Source

Standalone Install

Select an install method, to see config/commands for deploying Traefik (stack)

Installation method

Install on Portainer

Import all app templates into your Portainer instance, for easy 1-click deploys

  1. Ensure both Docker and Portainer are installed, and up-to-date
  2. Log into your Portainer web UI
  3. Under Settings → App Templates, paste the below URL
  4. Head to Home → App Templates, and the list of apps will show up
  5. Select Traefik (stack), fill in any config options, and hit Deploy

Template Import URL

https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me demo
Original stackfile

The compose file this template deploys, straight from its repo:

services:
  reverse-proxy:
    image: traefik:v3
    command: --api.insecure=true --providers.docker
    restart: unless-stopped
    ports:
      # The HTTP port
      - "80:80"
      # The Web UI (enabled by --api.insecure=true)
      - "8080:8080"
    volumes:
      # So that Traefik can listen to the Docker events (read-only)
      - /var/run/docker.sock:/var/run/docker.sock:ro

Or deploy it directly from the source:

git clone https://github.com/lissy93/portainer-templates
cd portainer-templates
docker compose -f sources/stacks/traefik.yml up -d

More install options in our documentation, or see traefik/traefik for app-specific guidance.

Quick reference

  • Maintained by:
[the Traefik Project](https://github.com/traefik/traefik-library-image)
  • Where to get help:
[the Docker Community Slack](https://dockr.ly/comm-slack), [Server Fault](https://serverfault.com/help/on-topic), [Unix & Linux](https://unix.stackexchange.com/help/on-topic), or [Stack Overflow](https://stackoverflow.com/help/on-topic)

Supported tags and respective Dockerfile links















Quick reference (cont.)

  • Where to file issues:
[https://github.com/traefik/traefik-library-image/issues](https://github.com/traefik/traefik-library-image/issues?q=)
[`amd64`](https://hub.docker.com/r/amd64/traefik/), [`arm32v6`](https://hub.docker.com/r/arm32v6/traefik/), [`arm64v8`](https://hub.docker.com/r/arm64v8/traefik/), [`ppc64le`](https://hub.docker.com/r/ppc64le/traefik/), [`riscv64`](https://hub.docker.com/r/riscv64/traefik/), [`s390x`](https://hub.docker.com/r/s390x/traefik/), [`windows-amd64`](https://hub.docker.com/r/winamd64/traefik/)
  • Published image artifact details:
[repo-info repo's `repos/traefik/` directory](https://github.com/docker-library/repo-info/blob/master/repos/traefik) ([history](https://github.com/docker-library/repo-info/commits/master/repos/traefik))  
(image metadata, transfer size, etc)
  • Image updates:
[official-images repo's `library/traefik` label](https://github.com/docker-library/official-images/issues?q=label%3Alibrary%2Ftraefik)  
[official-images repo's `library/traefik` file](https://github.com/docker-library/official-images/blob/master/library/traefik) ([history](https://github.com/docker-library/official-images/commits/master/library/traefik))
  • Source of this description:
[docs repo's `traefik/` directory](https://github.com/docker-library/docs/tree/master/traefik) ([history](https://github.com/docker-library/docs/commits/master/traefik))
logo
Traefik is a modern HTTP reverse proxy and ingress controller that makes deploying microservices easy.
Traefik integrates with your existing infrastructure components (Kubernetes, Docker, Swarm, Consul, Nomad, etcd, Amazon ECS, ...) and configures itself automatically and dynamically.
Pointing Traefik at your orchestrator should be the only configuration step you need.

Traefik v3 - Example usage

Enable docker provider and dashboard UI:
## traefik.yml

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

# API and dashboard configuration
api:
  insecure: true

Start Traefik v3:
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

Start a backend server using the traefik/whoami image:
docker run -d --name test traefik/whoami

Access the whoami service through Traefik via the defined rule test.docker.localhost:
$ curl test.docker.localhost
Hostname: 0693100b16de
IP: 127.0.0.1
IP: ::1
IP: 192.168.215.4
RemoteAddr: 192.168.215.3:57618
GET / HTTP/1.1
Host: test.docker.localhost
User-Agent: curl/8.7.1
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 192.168.215.1
X-Forwarded-Host: test.docker.localhost
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Server: 8a37fd4f35fb
X-Real-Ip: 192.168.215.1

Access the Traefik Dashboard:
Open your web browser and navigate to http://localhost:8080 to access the Traefik dashboard. This will provide an overview of routers, services, and middlewares.
Dashboard UI

Traefik v2 - Example usage

Enable docker provider and dashboard UI:
## traefik.yml

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

# API and dashboard configuration
api:
  insecure: true

Start Traefik v2:
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

Start a backend server using the traefik/whoami image:
docker run -d --name test traefik/whoami

Access the whoami service through Traefik via the defined rule test.docker.localhost:
$ curl test.docker.localhost
Hostname: 390a880bdfab
IP: 127.0.0.1
IP: 172.17.0.3
GET / HTTP/1.1
Host: test.docker.localhost
User-Agent: curl/7.65.3
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 172.17.0.1
X-Forwarded-Host: test.docker.localhost
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Server: 7e073cb54211
X-Real-Ip: 172.17.0.1

Access the Traefik Dashboard:
Open your web browser and navigate to http://localhost:8080 to access the Traefik dashboard. This will provide an overview of routers, services, and middlewares.
Dashboard UI

Documentation

You can find the complete documentation:

A community support is available at https://community.traefik.io

Image Variants

The traefik images come in many flavors, each designed for a specific use case.

traefik:<version>

This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.

traefik:<version>-windowsservercore

This image is based on Windows Server Core (mcr.microsoft.com/windows/servercore). As such, it only works in places which that image does, such as Windows 10 Professional/Enterprise (Anniversary Edition) or Windows Server 2016.
For information about how to get Docker running on Windows, please see the relevant "Quick Start" guide provided by Microsoft:

License

View license information for the software contained in this image.
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
Some additional license information which was able to be auto-detected might be found in the repo-info repository's traefik/ directory.
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Serve Traefik (stack) on your own domain behind Caddy, Nginx or Traefik. Fill in your domain and copy the result. It's a starting point, some apps need their own base URL or extra headers set too.

Proxying traefik-stack.example.com to http://reverse-proxy:80

Add this to your Caddyfile

traefik-stack.example.com {
	reverse_proxy http://reverse-proxy:80
}

Check the logs first

Nine times out of ten the logs tell you exactly what went wrong.

  • In Portainer, go to Containers, click the container, then Logs. Or run docker logs <container>
  • Exit codes help too: 137 means killed, usually out of memory. 126 or 127 means the command inside the image is broken.

Port already in use

If deployment fails with "Bind for 0.0.0.0:80 failed: port is already allocated", something else on your server is using that port.

  • Find what's using it: sudo ss -tlnp | grep :80
  • Stop the other service, or pick a different host port. In 80:80 only the left number is yours to change, the right one belongs to the app.

Running but the page won't load

The container is up but nothing appears in your browser.

  • Use your server's real IP: http://your-server-ip:80. The 0.0.0.0 link Portainer shows isn't a real address.
  • Give it a minute after first deploy, reverse-proxy can take a while to initialise.
  • Make sure your firewall allows the port, e.g. sudo ufw allow 80

Can't reach the Docker socket

reverse-proxy talks to Docker through /var/run/docker.sock. If the logs show "permission denied while trying to connect to the Docker daemon socket", the app's user can't access it.

  • Check the socket exists on the host: ls -l /var/run/docker.sock
  • Run the container as root, or add the docker group's id to the container with group_add.

Image won't pull

Test the pull directly on the host: docker pull traefik:v3

  • "manifest unknown" means the tag no longer exists.
  • "toomanyrequests" is the Docker Hub rate limit. Log in with docker login to raise it.
  • "no space left on device" means a full disk. Reclaim space with docker system prune

"exec format error"

This means the image was built for a different CPU architecture than your server.

  • This image supports: amd64, arm/v6, ppc64le, s390x, riscv64, arm64/v8
  • Check yours with uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.

Container keeps restarting

The unless-stopped restart policy relaunches the app after every crash, so the real error can scroll past.

  • Check the logs right after a restart, the last few lines before it died are the useful ones.
  • Get the exit code with docker inspect <container> --format '{{.State.ExitCode}}'
  • Still stuck? Redeploy once with the restart policy set to no so the failure stays visible.

Stack won't deploy

Compose stacks fail fast on small mistakes, and Portainer shows the reason just above the editor.

  • YAML only accepts spaces for indentation, a single tab breaks the whole file.

Raise an issue

Found something which isn't working as it should? Here's how to report it.

A Compose stack

Traefik (stack) is a Compose stack, a set of containers defined in one file and brought up together by Portainer, then started and stopped as a single app.

The app image

An image is the app packed up ready to go, everything Traefik (stack) needs bundled into one download. This template pulls traefik:v3, which Docker fetches once (about 167 MB) and then starts your own copy from.

Where the image comes from

Docker pulls its images from registries, public libraries of ready-built apps. Traefik (stack)'s comes from Docker Hub as one of its official, curated images.

Version tags

The bit after the colon in the image name is the version tag. This one pins v3, so every redeploy gives you that exact build until you bump it yourself.

Which machines it runs on

Every image is built for particular CPU types. This one ships for amd64, arm/v6, ppc64le, s390x, riscv64, arm64/v8, so it runs on both regular x86 servers and ARM boards like a Raspberry Pi.

Ports

A port is the door the app answers on. A mapping like 80:80 means it's reachable on port 80 of your server, where the left number is yours to change and the right one belongs to the app. Once it's running, open http://your-server-ip:80 in a browser. It opens:

  • 80:80, likely the web interface
  • 8080:8080, likely the web interface

Volumes

A volume is where Traefik (stack) keeps its files so they survive an update or a restart. Without one, anything it saves would sit inside the container and vanish the moment it's recreated. This template mounts:

  • /var/run/docker.sock from /var/run/docker.sock on the host (a socket it talks to, not storage)

Restart policy

The restart policy here is unless-stopped, so Docker restarts Traefik (stack) after a crash or reboot, but leaves it off when you stop it on purpose. You can change this on the deploy screen. The choices are no (never restart), on-failure (only after a crash), unless-stopped (restart unless you stop it), and always (bring it back no matter what).

Networking

Nothing custom is set, so Traefik (stack) sits on Docker's default bridge network: its own private space that reaches the outside world only through the ports it publishes.

Container name

Once it's deployed, Portainer names the container reverse-proxy. That's what you'll spot in the containers list and use in commands like docker logs reverse-proxy.

Startup command

The command is what runs the moment the container starts. This template sets its own, --api.insecure=true --providers.docker, in place of the image's default.

Platform

The platform is linux, the kind of system the container is built to run on. Docker and Portainer handle this on a normal Linux server.

Open source license

Traefik (stack) is open source, released under the MIT license. In plain terms the code is out in the open, so you're free to run it and change it to fit what you need.

Portainer app templates

Zooming out, this whole page comes from a Portainer app template: a short recipe telling Portainer how to set Traefik (stack) up. Add the template list to Portainer once, then deploying Traefik (stack) is a click rather than a wall of config.