Quick Start Guide
Get Traefik running with Docker in less than 5 minutes and see automatic service discovery in action.Prerequisites
Before you begin, ensure you have:- Docker installed and running on your system
- Basic familiarity with Docker and command line
- Ports 80 and 8080 available on your machine
This guide uses Docker Compose for simplicity. If you prefer another platform, check out our installation guide.
Step-by-Step Setup
Create a Docker Compose File
Create a new directory for your project and a Add the following content to
docker-compose.yml file:docker-compose.yml:Start Traefik and the Service
Launch the containers using Docker Compose:This command will:
- Pull the Traefik and whoami images (if not already present)
- Start both containers in detached mode
- Configure Traefik to automatically discover the whoami service
The first run may take a moment while Docker downloads the images.
Understanding the Configuration
Let’s break down what each part does:Traefik Container Configuration
web on port 80.
Docker Provider: Enables Traefik to automatically discover services from Docker. The exposedbydefault=false setting means containers must explicitly opt-in with labels.
API/Dashboard: Exposes the Traefik dashboard on port 8080 for monitoring and debugging.
Service Container Labels
traefik.enable=true: Tells Traefik to expose this containertraefik.http.routers.whoami.rule: Defines the routing rule (host-based)traefik.http.routers.whoami.entrypoints=web: Routes through thewebentrypoint
Adding More Services
To add another service, simply add it to yourdocker-compose.yml:
http://nginx.localhost - no additional Traefik configuration needed!
Next Steps
Congratulations! You now have Traefik running and automatically routing traffic to your services.Learn Core Concepts
Understand EntryPoints, Routers, Services, and Providers in depth
Production Installation
Deploy Traefik on Kubernetes, AWS ECS, or as a binary
Enable HTTPS
Set up automatic SSL/TLS with Let’s Encrypt
Add Middleware
Enhance your routes with authentication, rate limiting, and more
Troubleshooting
Service not accessible
Service not accessible
- Verify the container is running:
docker compose ps - Check Traefik logs:
docker logs traefik - Ensure the labels are correctly formatted
- Confirm the domain resolves to localhost
Dashboard not loading
Dashboard not loading
- Ensure port 8080 is not in use by another service
- Check that
--api.insecure=trueis in the command list - Verify the Traefik container is running
Cannot connect to Docker socket
Cannot connect to Docker socket
- Ensure Docker is running
- Verify the socket path is correct:
/var/run/docker.sock - On Windows/Mac, this should work with Docker Desktop