Skip to content

Instantly share code, notes, and snippets.

@gm50x
Created October 25, 2023 00:28
Show Gist options
  • Save gm50x/1e1f4672c252727322330e330c8690b1 to your computer and use it in GitHub Desktop.
Save gm50x/1e1f4672c252727322330e330c8690b1 to your computer and use it in GitHub Desktop.
Running docker containers (grafana, mongodb, rabbitmq) behind traefik
version: '3'
services:
traefik:
image: 'traefik:v2.10'
container_name: 'traefik'
command:
- '--api.insecure=true'
- '--providers.docker=true'
- '--providers.docker.exposedbydefault=false'
- '--entrypoints.web.address=:80'
- '--entrypoints.mongodb.address=:27017'
- '--entrypoints.amqp.address=:5672'
ports:
- '80:80'
- '8080:8080'
- '27017:27017'
- '5672:5672'
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:ro'
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.traefik.rule=Host(`traefik.localhost`)'
- 'traefik.http.routers.traefik.entrypoints=web'
- 'traefik.http.routers.traefik.service=traefik'
- 'traefik.http.services.traefik.loadbalancer.server.port=8080'
grafana:
image: grafana/grafana-oss
container_name: grafana
environment:
# GF_INSTALL_PLUGINS: 'grafana-clock-panel, grafana-simple-json-datasource, publicDashboards'
GF_SECURITY_ADMIN_USER: 'gedai'
GF_SERVER_DOMAIN: 'grafana.localhost'
GF_SERVER_ROOT_URL: 'http://grafana.localhost'
ports:
- '3000:3000'
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.grafana.rule=Host(`grafana.localhost`)'
- 'traefik.http.routers.grafana.entrypoints=web'
- 'traefik.http.routers.grafana.service=grafana'
- 'traefik.http.services.grafana.loadbalancer.server.port=3000'
mongodb:
image: mongo:6
container_name: mongodb
environment:
MONGO_INITDB_ROOT_USERNAME: 'gedai'
MONGO_INITDB_ROOT_PASSWORD: 'gedai'
labels:
- 'traefik.enable=true'
- 'traefik.tcp.routers.mongodb.rule=HostSNI(`*`)'
- 'traefik.tcp.routers.mongodb.entrypoints=mongodb'
- 'traefik.tcp.services.mongodb.loadbalancer.server.port=27017'
- 'traefik.tcp.routers.mongodb.service=mongodb'
rabbitmq:
image: rabbitmq:3-management
container_name: rabbitmq
hostname: rabbitmq
environment:
RABBITMQ_DEFAULT_USER: 'gedai'
RABBITMQ_DEFAULT_PASS: 'gedai'
labels:
- 'traefik.enable=true'
# amqp protocol
- 'traefik.tcp.routers.rabbitmq.rule=HostSNI(`*`)'
- 'traefik.tcp.routers.rabbitmq.entrypoints=amqp'
- 'traefik.tcp.services.rabbitmq.loadbalancer.server.port=5672'
- 'traefik.tcp.routers.rabbitmq.service=rabbitmq'
# Web Management GUI
- 'traefik.http.routers.rabbitmq-ui.entrypoints=web'
- 'traefik.http.routers.rabbitmq-ui.service=rabbitmq-ui'
- 'traefik.http.routers.rabbitmq-ui.rule=Host(`rabbitmq.localhost`)'
- 'traefik.http.services.rabbitmq-ui.loadbalancer.server.port=15672'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment