Excellent, that works! First step to a working solution
# run in certbot Docker container
apk add curl
apk add pcre-tools
/bin/sleep 20 # for service discovery to establish routing
DOMAINS=$(curl --silent --max-time 5 http://user:pass@traefik:8080/api/http/routers | \
pcregrep -o '(?<=Host\(`).*?(?=`\))' | sort | uniq)
for DOM in $DOMAINS; do
echo RENEW $DOM
certbot renew --standalone --non-interactive --agree-tos --no-eff-email --test-cert --cert-name $DOM
if [ $? -ne 0 ]; then
echo CREATE $DOM
certbot certonly --standalone --non-interactive --agree-tos --no-eff-email --test-cert -m mail@example.com -d $DOM
fi
done