{{tag>traefik docker mikrotik dns}}
====== Expose apps on local lan on DNS names via Traefik and Docker ======
This is an example of exposing Ampache on ampache.lan domain.
First, make sure that the above domain is set to point to whatever IP you are hosting the ampache at. You will need to resolve this domain on your local network. For example, in Mikrotik router, go to //IP>DNS>Static// and add an A record there.
Next, spin up a traefik container
services:
traefik:
image: traefik:v3.4
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
# Connect to the 'traefik_proxy' overlay network for inter-container communication across nodes
- proxy
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./certs:/certs:ro
- ./dynamic:/dynamic:ro
command:
# EntryPoints
- "--entrypoints.web.address=:80"
# Attach the static configuration tls.yaml file that contains the tls configuration settings
- "--providers.file.filename=/dynamic/tls.yaml"
# Providers
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=proxy"
# API & Dashboard
- "--api.dashboard=true"
- "--api.insecure=true"
# Observability
- "--log.level=INFO"
- "--accesslog=true"
- "--metrics.prometheus=true"
# Traefik Dynamic configuration via Docker labels
labels:
# Enable self‑routing
- "traefik.enable=true"
# Dashboard router
- "traefik.http.routers.dashboard.rule=Host(`rpi5.local`)"
- "traefik.http.routers.dashboard.service=api@internal"
networks:
proxy:
name: proxy
Your ampache needs to be on the same docker network as well. Also, labels are the way Traefik finds and routes to the apps, so make sure those are correct. Example file:
name: ampache
services:
ampache:
image: ampache/ampache:7.7.1
container_name: ampache
restart: unless-stopped
ports:
- 8010:80
volumes:
- ./data/config:/var/www/config
- ./data/log:/var/log/ampache
- ./data/media:/media
- ./data/mysql:/var/lib/mysql
- /export/bigassnas:/media/bigassnas
environment:
DISABLE_INOTIFYWAIT_CLEAN: ${DISABLE_INOTIFYWAIT_CLEAN-0}
labels:
- "traefik.enable=true"
- "traefik.http.routers.ampache.rule=Host(`ampache.lan`)"
- "traefik.http.routers.ampache.entrypoints=web"
- "traefik.http.services.ampache.loadbalancer.server.port=80"
networks:
- proxy
networks:
proxy:
name: proxy
external: true
On http://rpi5.local/ will be the Traefik dashboard and on http://ampache.lan should be ampache web ui.
Above configs don't have to be in the same docker-compose.yml file.
Example:
rpi5:~/docker/ampache# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
49532b7db10b ampache/ampache:7.7.1 "docker-entrypoint.s…" 34 minutes ago Up 34 minutes 0.0.0.0:8010->80/tcp, [::]:8010->80/tcp ampache
66a35b73b31a traefik:v3.4 "/entrypoint.sh --en…" 51 minutes ago Up 51 minutes 0.0.0.0:80->80/tcp, [::]:80->80/tcp, 0.0.0.0:443->443/tcp, [::]:443->443/tcp, 0.0.0.0:8080->8080/tcp, [::]:8080->8080/tcp traefik
====== Tested on ======
* Raspberry Pi 5b
====== See also ======
====== References ======
* https://doc.traefik.io/traefik/providers/docker/