Skip to content

Instantly share code, notes, and snippets.

@bozdoz
Created September 1, 2020 01:42
Show Gist options
  • Save bozdoz/f737867cafaa45193ed0a1f218997a38 to your computer and use it in GitHub Desktop.
Save bozdoz/f737867cafaa45193ed0a1f218997a38 to your computer and use it in GitHub Desktop.
Simple Traefik auto-discovery localhost Quick Start

Create a network for Traefik and any future containers to join:

docker network create web

Start up the traefik compose file:

docker-compose up -d

View the dashboard: http://localhost:8080

Start up the example compose file:

docker-compose -f docker-compose.whoami.yml up -d

View the newly created container: http://localhost:8000/whoami

version: '3'
services:
whoami:
# A container that exposes an API to show its IP address
image: containous/whoami
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=PathPrefix(`/whoami`)"
networks:
default:
external:
name: web
version: '3'
services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.2
# Enables the web UI and tells Traefik to listen to docker
command: --api.insecure=true --providers.docker
ports:
# The HTTP port
- "8000:80"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock:ro
# add traefik to the web network so that it can send traffic to other containers
networks:
default:
external:
name: web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment