I have a pretty basic traefik setup going, using letsencrypt to get certificates and so on.
First I start a whoami
container and serve it on my public ip. Good. Next I launch a second whoami
. Let me show you the docker-compose.yaml
version: '3'
services:
whoami:
image: containous/whoami
restart: always
networks:
- traefik
labels:
- traefik.enable=true
- traefik.http.routers.r2.rule=Host(`whoareyou.example.com`)
- traefik.http.routers.r2.tls=true
- traefik.http.routers.r2.tls.certresolver=letsencrypt
- traefik.http.routers.r2.middlewares=SecureSslHeaders@file,compressor@file
networks:
traefik:
external: true
Notice how I had to change the file quite a few places, especially the route name bugs me - where I had to add a 2
on every line. This calls for typos.
Would have been nice to have a SELF macro to put in there.
Of course this a simplified example, but I do quite often find my self copying a docker-compose.yaml
to a different folder just to try something out. If I forget to rename the instance names, in this example the route name, I am likely to break the source container when the new one overwrites something important, simply because of a name clash. The same goes with services and middlewares.
Any fool proof suggestions?
I have recently migrated from 1.7 where I found things easier/simpler.