maybe is a stupid question...but it's possibile to put variable into docker labels of docker-compose.yml file?
my .env file:
HOST_1=www.example.com
HOST_2=www.site.com
into my docker-compose.yml file can you write like this?
services:
site_01:
...
labels:
- "traefik.http.routers.site_01.rule=Host(`${HOST_1}`)"
- "traefik.http.services.site_01.loadbalancer.server.port=80"
site_02:
...
labels:
- "traefik.http.routers.site_02.rule=Host(`${HOST_2}`)"
- "traefik.http.services.site_02.loadbalancer.server.port=80"
Thanks
Yes it is possible and your snippet seem correct. You can check if the labels are there with docker inspect <container_name_or_id>
.
It is also possible to add labels at the build stage. The syntax is the same but labels:
key must be under build:
key.