Traefik (container)
Cloud-Native Networking Stack That Just Works.
Image details
Configuration
TypeContainerlinuxtraefik:latest80:80/tcp443:443/tcp8080:8080/tcp/traefik.yml : /portainer/Files/AppData/Config/traefik/traefik.yml/config.yml : /portainer/Files/AppData/Config/traefik/config.yml/acme.json : /portainer/Files/AppData/Config/traefik/acme.json/var/run/docker.sock : /var/run/docker.sockunless-stoppedTemplate by novaspirit
Notes
Check our Github page: https://github.com/pi-hosted/pi-hosted
Official Webpage: https://doc.traefik.io/traefik/
Official Docker Documentation: https://doc.traefik.io/traefik/getting-started/install-traefik/
Pre-installation script must be RAN before you install: wget -qO- https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/tools/traefik.sh | bash
A simple and lightweight reverse proxy
Standalone Install
Select an install method, to see config/commands for deploying Traefik (container)
Install on Portainer
Import all app templates into your Portainer instance, for easy 1-click deploys
- Ensure both Docker and Portainer are installed, and up-to-date
- Log into your Portainer web UI
- Under Settings → App Templates, paste the below URL
- Head to Home → App Templates, and the list of apps will show up
- Select Traefik (container), fill in any config options, and hit Deploy
Template Import URL
https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me
More install options in our documentation.
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=)- Supported architectures: (more info)
[`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))
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
Enabledocker provider and dashboard UI:## traefik.yml
# Docker configuration backend
providers:
docker:
defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"
# API and dashboard configuration
api:
insecure: trueStart 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:v3Start a backend server using the
traefik/whoami image:docker run -d --name test traefik/whoamiAccess 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.1Access 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.
Traefik v2 - Example usage
Enabledocker provider and dashboard UI:## traefik.yml
# Docker configuration backend
providers:
docker:
defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"
# API and dashboard configuration
api:
insecure: trueStart 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.11Start a backend server using the
traefik/whoami image:docker run -d --name test traefik/whoamiAccess 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.1Access 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.
Documentation
You can find the complete documentation:A community support is available at https://community.traefik.io
Image Variants
Thetraefik 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 (container) 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-container.example.com to http://traefik:80
Add this to your Caddyfile
traefik-container.example.com {
reverse_proxy http://traefik: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 traefik - Exit codes help too:
137means killed, usually out of memory.126or127means 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:80only 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, traefik can take a while to initialise.
- Make sure your firewall allows the port, e.g.
sudo ufw allow 80
Permission denied on volumes
If the logs show "permission denied", the app can't write to its data folder on the host.
- Fix the ownership:
sudo chown -R 1000:1000 /portainer/Files/AppData/Config/traefik/traefik.yml(and the same for the other mapped folders)
Can't reach the Docker socket
traefik 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:latest
- "manifest unknown" means the tag no longer exists. This template uses
latest, so try pinning a specific version instead. - "toomanyrequests" is the Docker Hub rate limit. Log in with
docker loginto 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 traefik --format '{{.State.ExitCode}}' - Still stuck? Redeploy once with the restart policy set to
noso the failure stays visible.
Raise an issue
Found something which isn't working as it should? Here's how to report it.
- Bug within the app: Open an issue within traefik's repo
- Template not working: Open an issue on novaspirit/pi-hosted
- This website not working: Open an issue on lissy93/portainer-templates
A single container
Traefik (container) runs as one container, the simplest kind of app here. Just the one image to pull and nothing else wired up alongside it.
The app image
An image is the app packed up ready to go, everything Traefik (container) needs bundled into one download. This template pulls traefik:latest, 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 (container)'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. Here it's latest, which always points at the newest build, so a redeploy can bump you to a newer release without you asking. Newest right now is 3.6.25-nanoserver-ltsc2022. Pin a specific tag if you would rather stay on one version.
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 interface443:443, likely the web interface8080:8080, likely the web interface
Volumes
A volume is where Traefik (container) 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:
/traefik.ymlfrom/portainer/Files/AppData/Config/traefik/traefik.ymlon the host/config.ymlfrom/portainer/Files/AppData/Config/traefik/config.ymlon the host/acme.jsonfrom/portainer/Files/AppData/Config/traefik/acme.jsonon the host/var/run/docker.sockfrom/var/run/docker.sockon the host (a socket it talks to, not storage)
Restart policy
The restart policy here is unless-stopped, so Docker restarts Traefik (container) 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 (container) 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 traefik. That's what you'll spot in the containers list and use in commands like docker logs traefik.
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.
Portainer app templates
Zooming out, this whole page comes from a Portainer app template: a short recipe telling Portainer how to set Traefik (container) up. Add the template list to Portainer once, then deploying Traefik (container) is a click rather than a wall of config.
Muximux Proxy
Nginx Proxy Manager (container) Proxy
Nginx Proxy Manager (stack) Proxy
Nginx Proxy Manager v2 with Sqlite and Goaccess Charts Proxy
Nginx Proxy Manager v2 with Sqllite Proxy
Nginx Proxy Manager v3 [DEVEL] NOT READY FOR USE Proxy
Adguardhome (container) Tools
Alpine Xfce4 noVNC Tools
Apache Httpd Proxy
Arcane Tools
ArchiSteamFarm Tools
Archivebox Tools