acme.sh: Restart server in docker not working

327 Views Asked by At

I use acme.sh to install a SSL-certificate to a nginx-server, which runs in a docker-container. This worked fine.

I now want to make a cronjob to regularly check and perhaps renew the certificate. This is what I tried:

0 0 * * * sh $MYHOMEDIR/.acme.sh/acme.sh --cron --home $MYHOMEDIR/.acme.sh --reloadcmd "docker compose -f $MYHOME_DIR/docker/my-app/docker-compose.yaml restart"

This is renewing the certificate when needed, but it's not restarting the container.

I found somewhere that --cron doesn't work with reloadcmd, so I tried:

0 0 * * * sh $MYHOMEDIR/.acme.sh/acme.sh --cron --home $MYHOMEDIR/.acme.sh --renew-hook "docker compose -f $MYHOME_DIR/docker/my-app/docker-compose.yaml restart"

But with the same result: The certificate is renewed, but the container is not restarted.

Any ideas?

1

There are 1 best solutions below

1
On

Most likely cron does not run inside your container, but from the amount of info you provided, it is very hard to figure out. Dockerfile? docker-compose.yml (or the exact command you used to start your container)?