How to use Traefik as a reverse proxy for containers
Updated 11/29/2026
Traefik is a reverse proxy built for containers: it discovers services automatically and gets them HTTPS certificates with no manual configuration. Perfect when you run multiple apps on one server.
1. The Traefik service in Compose
services:
traefik:
image: traefik:v3.0
command:
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "[email protected]"
- "--certificatesresolvers.le.acme.storage=/acme.json"
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./acme.json:/acme.json
2. Label the app
Add labels to your service so Traefik knows where to send traffic:
app:
image: my-app
labels:
- "traefik.http.routers.app.rule=Host(`example.com`)"
- "traefik.http.routers.app.tls.certresolver=le"
3. Start
docker compose up -d
Traefik detects the app, exposes it on the given domain and automatically obtains an HTTPS certificate. For the Nginx version, see Nginx as a reverse proxy.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
How networking works in Docker
Understand how containers communicate with each other and how to isolate them on separate Docker networks.
Updated 11/29/2026Docker & containersHow to keep data in Docker with volumes
Containers are ephemeral: without volumes, you lose data when you delete the container. Here is how to keep it correctly.
Updated 11/29/2026Docker & containersHow to free up disk space used by Docker
Images, stopped containers and orphaned volumes can fill your disk. Here is how to clean them up safely.
Updated 11/29/2026