Using certbot in docker to create multiple certs

I'm looking to get separate certificates for each domain using the certbot/certbot docker container. I understand to do that outside docker you'd run certbot once per domain. Inside a container I see --cert-name is a method of to achieve this (at least based on old docs) however I'm failing to get it to work.

certonly --webroot --email email@domain.tld --agree-tos --no-eff-email --cert-name -w /var/www/html/  -d  --cert-name domain2.tld -w /var/www/html/ -d server.domain2.tld

What I'm seeing is a single cert with an alternative name.

Is there a way to run certbot multiple times within the docker container? Or is there a correct sequence to get it to honor cert-name?

Hi @raccettura and welcome to the LE community forum :slight_smile:

If you force a cert-name then the resulting cert will replace the previous one with that same name.
If you don't want one cert with many names on it, you will have to use multiple cert names (or let certbot name the certs for you).
If you are trying to obtain multiple certs with one call of certbot, that is not necessary.
You can call certbot as many times as you need new certs.

certonly --cert-name \
--webroot -w /path/to/domain1 -d \
--email email@domain1.tld --agree-tos --no-eff-email

certonly --cert-name \
--webroot -w /path/to/domain2 -d \
--email email@domain2.tld --agree-tos --no-eff-email

certonly --cert-name \
--webroot -w /path/to/domain3 -d \
--email email@domain3.tld --agree-tos --no-eff-email
1 Like

Hi, and thanks for the quick response.

The only reason I'm not running the certonly command multiple times is because the certbot docker container seems designed to only take a single command. I'd like to avoid running 20 containers for 20 domains.

Can you run one command at a time?
[in the same container]

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.