Quiero saber si se puede hacer y si es así cómo hacerlo, como poder leer las etiquetas de entorno de otros dockers.
Les dejo un ejemplo de lo que he visto y no consigo encontrar información con la que entender cómo lo hace (docker compose):
version: '3'
services:
nginx-proxy:
image: budry/jwilder-nginx-proxy-arm:0.6.0
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- certs:/etc/nginx/certs:ro
- confd:/etc/nginx/conf.d
- vhostd:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
labels:
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion:stable
restart: always
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- certs:/etc/nginx/certs:ro
- confd:/etc/nginx/conf.d
- vhostd:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
nginx:
image: tobi312/php:7.4-fpm-nginx-alpine-arm
restart: always
expose:
- "80"
environment:
- VIRTUAL_HOST=example.host.com
- LETSENCRYPT_HOST=example.host.com
- LETSENCRYPT_EMAIL=example@mail.com
volumes:
certs:
html:
vhostd:
confd:
En este ejemplo se puede ver que: los contenedores nginx-proxy
y letsencrypt
son capaces de leer las etiquetas VIRTUAL_HOST
, LETSENCRYPT_HOST
y LETSENCRYPT_EMAIL
. Mi pregunta es, ¿cómo lo hacen y cómo puedo hacerlo yo? Me gustaría usar esto en un dockerFile, pero me espero cualquier cosa...
Esta duda aparece por lo que aquí se explica (nginx-proxy)
Gracias de antemano por cualquier ayuda
LETSENCRYPT_HOST in:docker-letsencrypt-nginx-proxy-companion
UPDATE:
Encontre este codigo entre los archivos de letsencrypt
y algo similar entre los archivos de nginx(pero más largo). Creo que lo que estoy buscando es algo así, pero no se ni entiendo lo que hace exactamente
LETSENCRYPT_CONTAINERS=({{ range $host, $containers := groupBy $ "Env.LETSENCRYPT_HOST" }}{{ range $container := $containers }} '{{ printf "%.12s" $container.ID }}' {{ end }}{{ end }})
{{ range $hosts, $containers := groupBy $ "Env.LETSENCRYPT_HOST" }}
{{ range $container := $containers }}{{ $cid := printf "%.12s" $container.ID }}
LETSENCRYPT_{{ $cid }}_HOST=( {{ range $host := split $hosts "," }}'{{ $host }}' {{ end }})
LETSENCRYPT_{{ $cid }}_EMAIL="{{ $container.Env.LETSENCRYPT_EMAIL }}"
LETSENCRYPT_{{ $cid }}_TEST="{{ $container.Env.LETSENCRYPT_TEST }}"
{{ end }}
{{ end }}
(Que use la variable $containers
y que contenga Env.LETSENCRYPT_HOST
me da a entender que esta leyendo las enviorement
declaradas en otros contenedores)