I have the script below running as a container within docker compose using the image certbot/certbot
All goes well with the initial certificate issuance, but the script is giving an error on the line
certbot renew -v -n "$OPT_TEST_CERT" "$OPT_DRY_RUN"
However if I open a shell on the container and run the command it works ($OPT_DRY_RUN was not set)
/opt/certbot # certbot renew -n --test-cert
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Processing /etc/letsencrypt/renewal/test.growler.co.za.conf
Certificate not yet due for renewal
The following certificates are not due for renewal yet:
/etc/letsencrypt/live/test.growler.co.za/fullchain.pem expires on 2025-06-20 (skipped)
No renewals were attempted.
The error output that I see is as follows:
certbot-1 | Sat Mar 22 10:10:02 UTC 2025: Starting certificate renewal process ... OPT_TEST_CERT=--test-cert, OPT_DRY_RUN=
certbot-1 | Sat Mar 22 10:10:02 UTC 2025: > certbot renew -v -n --test-cert
certbot-1 | usage:
certbot-1 | certbot [SUBCOMMAND] [options] [-d DOMAIN] [-d DOMAIN] ...
certbot-1 |
certbot-1 | Certbot can obtain and install HTTPS/TLS/SSL certificates. By default,
certbot-1 | it will attempt to use a webserver both for obtaining and installing the
certbot-1 | certificate.
certbot-1 | certbot: error: unrecognized arguments:
#!/bin/sh
trap exit TERM
OPT_TEST_CERT="--test-cert"
# OPT_DRY_RUN="--dry-run"
OPT_DRY_RUN=""
[ ! "$DRY_RUN" = "true" ] && OPT_DRY_RUN=""
rm -f /var/www/certbot/.certbot-started
echo "$(date): certbot container started ... OPT_TEST_CERT=$OPT_TEST_CERT, OPT_DRY_RUN=$OPT_DRY_RUN"
# Check if certificates exist
if ! certbot certificates | grep "Certificate Name: test.growler.co.za"; then
GROWLER_WEBROOT="/var/www/certbot/test.growler.co.za"
[ ! -d "$GROWLER_WEBROOT" ] && mkdir -p "$GROWLER_WEBROOT"
echo "$(date): Initial certificate acquisition for test.growler.co.za"
certbot certonly --webroot -v -w "$GROWLER_WEBROOT" -d test.growler.co.za --email admin@growler.co.za -n --agree-tos --no-eff-email "$OPT_TEST_CERT"
fi
touch /var/www/certbot/.certbot-started
while :; do
echo "$(date): Starting certificate renewal process ... OPT_TEST_CERT=$OPT_TEST_CERT, OPT_DRY_RUN=$OPT_DRY_RUN"
echo "$(date): > certbot renew -v -n $OPT_TEST_CERT $OPT_DRY_RUN"
certbot renew -v -n "$OPT_TEST_CERT" "$OPT_DRY_RUN"
sleep 12h
done